diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 33 | ||||
-rw-r--r-- | src/nvim/fileio.c | 51 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/memfile.c | 24 | ||||
-rw-r--r-- | src/nvim/normal.c | 33 | ||||
-rw-r--r-- | src/nvim/normal.h | 41 | ||||
-rw-r--r-- | src/nvim/ops.c | 184 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 40 | ||||
-rw-r--r-- | src/nvim/options.lua | 1 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 13 | ||||
-rw-r--r-- | src/nvim/os/users.c | 6 | ||||
-rw-r--r-- | src/nvim/shada.c | 4 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
13 files changed, 220 insertions, 214 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 762cd3efd3..a6e3fedd3f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -918,13 +918,15 @@ do_buffer ( if (buf == NULL) { /* could not find it */ if (start == DOBUF_FIRST) { - /* don't warn when deleting */ - if (!unload) - EMSGN(_("E86: Buffer %" PRId64 " does not exist"), count); - } else if (dir == FORWARD) + // don't warn when deleting + if (!unload) { + EMSGN(_(e_nobufnr), count); + } + } else if (dir == FORWARD) { EMSG(_("E87: Cannot go beyond last buffer")); - else + } else { EMSG(_("E88: Cannot go before first buffer")); + } return FAIL; } @@ -1711,18 +1713,15 @@ static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id, return NULL; } -/* - * Find file in buffer list by a regexp pattern. - * Return fnum of the found buffer. - * Return < 0 for error. - */ -int -buflist_findpat ( - char_u *pattern, - char_u *pattern_end, /* pointer to first char after pattern */ - int unlisted, /* find unlisted buffers */ - int diffmode, /* find diff-mode buffers only */ - int curtab_only /* find buffers in current tab only */ +/// Find file in buffer list by a regexp pattern. +/// Return fnum of the found buffer. +/// Return < 0 for error. +int buflist_findpat( + const char_u *pattern, + const char_u *pattern_end, // pointer to first char after pattern + int unlisted, // find unlisted buffers + int diffmode, // find diff-mode buffers only + int curtab_only // find buffers in current tab only ) { int match = -1; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 1a6c85abaa..23292ff4ac 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3368,16 +3368,16 @@ restore_backup: nchars += len; } -#if defined(UNIX) && defined(HAVE_FSYNC) - /* On many journalling file systems there is a bug that causes both the - * original and the backup file to be lost when halting the system right - * after writing the file. That's because only the meta-data is - * journalled. Syncing the file slows down the system, but assures it has - * been written to disk and we don't lose it. - * For a device do try the fsync() but don't complain if it does not work - * (could be a pipe). - * If the 'fsync' option is FALSE, don't fsync(). Useful for laptops. */ - if (p_fs && fsync(fd) != 0 && !device) { +#if defined(UNIX) + // On many journalling file systems there is a bug that causes both the + // original and the backup file to be lost when halting the system right + // after writing the file. That's because only the meta-data is + // journalled. Syncing the file slows down the system, but assures it has + // been written to disk and we don't lose it. + // For a device do try the fsync() but don't complain if it does not work + // (could be a pipe). + // If the 'fsync' option is FALSE, don't fsync(). Useful for laptops. + if (p_fs && os_fsync(fd) != 0 && !device) { errmsg = (char_u *)_("E667: Fsync failed"); end = 0; } @@ -7096,26 +7096,23 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname) return FALSE; } -/* - * Convert the given pattern "pat" which has shell style wildcards in it, into - * a regular expression, and return the result in allocated memory. If there - * is a directory path separator to be matched, then TRUE is put in - * allow_dirs, otherwise FALSE is put there -- webb. - * Handle backslashes before special characters, like "\*" and "\ ". - * - * Returns NULL on failure. - */ -char_u * -file_pat_to_reg_pat ( - char_u *pat, - char_u *pat_end, /* first char after pattern or NULL */ - char *allow_dirs, /* Result passed back out in here */ - int no_bslash /* Don't use a backward slash as pathsep */ +/// Convert the given pattern "pat" which has shell style wildcards in it, into +/// a regular expression, and return the result in allocated memory. If there +/// is a directory path separator to be matched, then TRUE is put in +/// allow_dirs, otherwise FALSE is put there -- webb. +/// Handle backslashes before special characters, like "\*" and "\ ". +/// +/// Returns NULL on failure. +char_u * file_pat_to_reg_pat( + const char_u *pat, + const char_u *pat_end, // first char after pattern or NULL + char *allow_dirs, // Result passed back out in here + int no_bslash // Don't use a backward slash as pathsep ) { - char_u *endp; + const char_u *endp; char_u *reg_pat; - char_u *p; + const char_u *p; int nested = 0; int add_dollar = TRUE; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 52eebebf41..d68e952693 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -2,6 +2,7 @@ #define NVIM_GLOBALS_H #include <stdbool.h> +#include <inttypes.h> // EXTERN is only defined in main.c. That's where global variables are // actually defined and initialized. @@ -1239,6 +1240,7 @@ EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_maxmempat[] INIT(= N_( "E363: pattern uses more memory than 'maxmempattern'")); EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer")); +EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %" PRId64 " does not exist")); EXTERN char_u e_invalpat[] INIT(= N_( "E682: Invalid search pattern or delimiter")); diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 3df4cbc4a3..9f5e4247b5 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -460,31 +460,11 @@ int mf_sync(memfile_T *mfp, int flags) mfp->mf_dirty = false; if ((flags & MFS_FLUSH) && *p_sws != NUL) { -#if defined(UNIX) -# ifdef HAVE_FSYNC if (STRCMP(p_sws, "fsync") == 0) { - if (fsync(mfp->mf_fd)) + if (os_fsync(mfp->mf_fd)) { status = FAIL; - } else { -# endif - // OpenNT is strictly POSIX (Benzinger). - // Tandem/Himalaya NSK-OSS doesn't have sync() -# if defined(__OPENNT) || defined(__TANDEM) - fflush(NULL); -# else - sync(); -# endif -# ifdef HAVE_FSYNC + } } -# endif -#endif -# ifdef SYNC_DUP_CLOSE - // Win32 is a bit more work: Duplicate the file handle and close it. - // This should flush the file to disk. - int fd; - if ((fd = dup(mfp->mf_fd)) >= 0) - close(fd); -# endif } got_int |= got_int_save; diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a2e473fcb8..d4bf1c2e90 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1601,7 +1601,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (VIsual_mode == Ctrl_V) { /* block mode */ colnr_T start, end; - oap->block_mode = true; + oap->motion_type = MBLOCK; getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, &oap->end_vcol); @@ -1711,11 +1711,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) */ if (oap->motion_force == NUL || oap->motion_type == MLINE) oap->inclusive = true; - if (VIsual_mode == 'V') + if (VIsual_mode == 'V') { oap->motion_type = MLINE; - else { + } else if (VIsual_mode == 'v') { oap->motion_type = MCHAR; - if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL + if (*ml_get_pos(&(oap->end)) == NUL && (include_line_break || !virtual_op) ) { oap->inclusive = false; @@ -1780,7 +1780,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) * oap->empty is set when start and end are the same. The inclusive * flag affects this too, unless yanking and the end is on a NUL. */ - oap->empty = (oap->motion_type == MCHAR + oap->empty = (oap->motion_type != MLINE && (!oap->inclusive || (oap->op_type == OP_YANK && gchar_pos(&oap->end) == NUL)) @@ -1810,14 +1810,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) * first non-blank in the line, the operator becomes linewise * (strange, but that's the way vi does it). */ - if ( oap->motion_type == MCHAR - && oap->inclusive == false - && !(cap->retval & CA_NO_ADJ_OP_END) - && oap->end.col == 0 - && (!oap->is_VIsual || *p_sel == 'o') - && !oap->block_mode - && oap->line_count > 1) { - oap->end_adjusted = true; /* remember that we did this */ + if (oap->motion_type == MCHAR + && oap->inclusive == false + && !(cap->retval & CA_NO_ADJ_OP_END) + && oap->end.col == 0 + && (!oap->is_VIsual || *p_sel == 'o') + && oap->line_count > 1) { + oap->end_adjusted = true; // remember that we did this --oap->line_count; --oap->end.lnum; if (inindent(0)) @@ -2044,7 +2043,6 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) } else { curwin->w_cursor = old_cursor; } - oap->block_mode = false; clearop(oap); } curwin->w_p_lbr = lbr_saved; @@ -2115,12 +2113,13 @@ static void op_function(oparg_T *oap) /* Exclude the end position. */ decl(&curbuf->b_op_end); - if (oap->block_mode) + if (oap->motion_type == MBLOCK) { argv[0] = (char_u *)"block"; - else if (oap->motion_type == MLINE) + } else if (oap->motion_type == MLINE) { argv[0] = (char_u *)"line"; - else + } else { argv[0] = (char_u *)"char"; + } /* Reset virtual_op so that 'virtualedit' can be changed in the * function. */ diff --git a/src/nvim/normal.h b/src/nvim/normal.h index 01259de6cd..95619c7ef6 100644 --- a/src/nvim/normal.h +++ b/src/nvim/normal.h @@ -14,28 +14,27 @@ * Arguments for operators. */ typedef struct oparg_S { - int op_type; /* current pending operator type */ - int regname; /* register to use for the operator */ - int motion_type; /* type of the current cursor motion */ - int motion_force; /* force motion type: 'v', 'V' or CTRL-V */ - bool use_reg_one; /* true if delete uses reg 1 even when not - linewise */ - bool inclusive; /* true if char motion is inclusive (only - valid when motion_type is MCHAR */ - bool end_adjusted; /* backuped b_op_end one char (only used by - do_format()) */ - pos_T start; /* start of the operator */ - pos_T end; /* end of the operator */ - pos_T cursor_start; /* cursor position before motion for "gw" */ + int op_type; // current pending operator type + int regname; // register to use for the operator + int motion_type; // type of the current cursor motion + int motion_force; // force motion type: 'v', 'V' or CTRL-V + bool use_reg_one; // true if delete uses reg 1 even when not + // linewise + bool inclusive; // true if char motion is inclusive (only + // valid when motion_type is MCHAR) + bool end_adjusted; // backuped b_op_end one char (only used by + // do_format()) + pos_T start; // start of the operator + pos_T end; // end of the operator + pos_T cursor_start; // cursor position before motion for "gw" - long line_count; /* number of lines from op_start to op_end - (inclusive) */ - bool empty; /* op_start and op_end the same (only used by - op_change()) */ - bool is_VIsual; /* operator on Visual area */ - bool block_mode; /* current operator is Visual block mode */ - colnr_T start_vcol; /* start col for block mode operator */ - colnr_T end_vcol; /* end col for block mode operator */ + long line_count; // number of lines from op_start to op_end + // (inclusive) + bool empty; // op_start and op_end the same (only used by + // op_change()) + bool is_VIsual; // operator on Visual area + colnr_T start_vcol; // start col for block mode operator + colnr_T end_vcol; // end col for block mode operator long prev_opcount; // ca.opcount saved for K_EVENT long prev_count0; // ca.count0 saved for K_EVENT } oparg_T; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 52b4fed9d7..c3d968ca51 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -174,20 +174,20 @@ void op_shift(oparg_T *oap, int curs_top, int amount) (linenr_T)(oap->end.lnum + 1)) == FAIL) return; - if (oap->block_mode) + if (oap->motion_type == MBLOCK) { block_col = curwin->w_cursor.col; + } for (i = oap->line_count - 1; i >= 0; i--) { first_char = *get_cursor_line_ptr(); - if (first_char == NUL) /* empty line */ + if (first_char == NUL) { // empty line curwin->w_cursor.col = 0; - else if (oap->block_mode) + } else if (oap->motion_type == MBLOCK) { shift_block(oap, amount); - else - /* Move the line right if it doesn't start with '#', 'smartindent' - * isn't set or 'cindent' isn't set or '#' isn't in 'cino'. */ - if (first_char != '#' || !preprocs_left()) { - shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE); + } else if (first_char != '#' || !preprocs_left()) { + // Move the line right if it doesn't start with '#', 'smartindent' + // isn't set or 'cindent' isn't set or '#' isn't in 'cino'. + shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, false); } ++curwin->w_cursor.lnum; } @@ -196,7 +196,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount) /* The cursor line is not in a closed fold */ foldOpenCursor(); - if (oap->block_mode) { + if (oap->motion_type == MBLOCK) { curwin->w_cursor.lnum = oap->start.lnum; curwin->w_cursor.col = block_col; } else if (curs_top) { /* put cursor on first line, for ">>" */ @@ -703,17 +703,16 @@ char_u *get_expr_line_src(void) /// @param writing allow only writable registers bool valid_yank_reg(int regname, bool writing) { - if ( (regname > 0 && ASCII_ISALNUM(regname)) - || (!writing && vim_strchr((char_u *) - "/.%#:=" - , regname) != NULL) - || regname == '"' - || regname == '-' - || regname == '_' - || regname == '*' - || regname == '+' - ) + if ((regname > 0 && ASCII_ISALNUM(regname)) + || (!writing && vim_strchr((char_u *) "/.%:=" , regname) != NULL) + || regname == '#' + || regname == '"' + || regname == '-' + || regname == '_' + || regname == '*' + || regname == '+') { return true; + } return false; } @@ -1275,8 +1274,9 @@ cmdline_paste_reg ( || (i < reg->y_size - 1 && !(remcr && i == reg->y_size - 2 - && *reg->y_array[i + 1] == NUL))) + && *reg->y_array[i + 1] == NUL))) { cmdline_paste_str((char_u *)"\r", literally); + } /* Check for CTRL-C, in case someone tries to paste a few thousand * lines and gets bored. */ @@ -1321,12 +1321,11 @@ int op_delete(oparg_T *oap) * line and motion_type == MCHAR and the result is a blank line, make the * delete linewise. Don't do this for the change command or Visual mode. */ - if ( oap->motion_type == MCHAR - && !oap->is_VIsual - && !oap->block_mode - && oap->line_count > 1 - && oap->motion_force == NUL - && oap->op_type == OP_DELETE) { + if (oap->motion_type == MCHAR + && !oap->is_VIsual + && oap->line_count > 1 + && oap->motion_force == NUL + && oap->op_type == OP_DELETE) { ptr = ml_get(oap->end.lnum) + oap->end.col; if (*ptr != NUL) ptr += oap->inclusive; @@ -1339,20 +1338,20 @@ int op_delete(oparg_T *oap) * Check for trying to delete (e.g. "D") in an empty line. * Note: For the change operator it is ok. */ - if ( oap->motion_type == MCHAR - && oap->line_count == 1 - && oap->op_type == OP_DELETE - && *ml_get(oap->start.lnum) == NUL) { - /* - * It's an error to operate on an empty region, when 'E' included in - * 'cpoptions' (Vi compatible). - */ - if (virtual_op) - /* Virtual editing: Nothing gets deleted, but we set the '[ and '] - * marks as if it happened. */ + if (oap->motion_type != MLINE + && oap->line_count == 1 + && oap->op_type == OP_DELETE + && *ml_get(oap->start.lnum) == NUL) { + // It's an error to operate on an empty region, when 'E' included in + // 'cpoptions' (Vi compatible). + if (virtual_op) { + // Virtual editing: Nothing gets deleted, but we set the '[ and '] + // marks as if it happened. goto setmarks; - if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL) + } + if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL) { beep_flush(); + } return OK; } @@ -1403,10 +1402,11 @@ int op_delete(oparg_T *oap) /* * block mode delete */ - if (oap->block_mode) { + if (oap->motion_type == MBLOCK) { if (u_save((linenr_T)(oap->start.lnum - 1), - (linenr_T)(oap->end.lnum + 1)) == FAIL) + (linenr_T)(oap->end.lnum + 1)) == FAIL) { return FAIL; + } for (lnum = curwin->w_cursor.lnum; lnum <= oap->end.lnum; ++lnum) { block_prep(oap, &bd, lnum, TRUE); @@ -1594,7 +1594,7 @@ int op_delete(oparg_T *oap) msgmore(curbuf->b_ml.ml_line_count - old_lcount); setmarks: - if (oap->block_mode) { + if (oap->motion_type == MBLOCK) { curbuf->b_op_end.lnum = oap->end.lnum; curbuf->b_op_end.col = oap->start.col; } else @@ -1655,7 +1655,7 @@ int op_replace(oparg_T *oap, int c) /* * block mode replace */ - if (oap->block_mode) { + if (oap->motion_type == MBLOCK) { bd.is_MAX = (curwin->w_curswant == MAXCOL); for (; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum) { curwin->w_cursor.col = 0; /* make sure cursor position is valid */ @@ -1837,7 +1837,7 @@ void op_tilde(oparg_T *oap) return; pos = oap->start; - if (oap->block_mode) { /* Visual block mode */ + if (oap->motion_type == MBLOCK) { // Visual block mode for (; pos.lnum <= oap->end.lnum; ++pos.lnum) { int one_change; @@ -1999,11 +1999,11 @@ void op_insert(oparg_T *oap, long count1) curwin->w_cursor.lnum = oap->start.lnum; update_screen(INVERTED); - if (oap->block_mode) { - /* When 'virtualedit' is used, need to insert the extra spaces before - * doing block_prep(). When only "block" is used, virtual edit is - * already disabled, but still need it when calling - * coladvance_force(). */ + if (oap->motion_type == MBLOCK) { + // When 'virtualedit' is used, need to insert the extra spaces before + // doing block_prep(). When only "block" is used, virtual edit is + // already disabled, but still need it when calling + // coladvance_force(). if (curwin->w_cursor.coladd > 0) { int old_ve_flags = ve_flags; @@ -2025,7 +2025,7 @@ void op_insert(oparg_T *oap, long count1) } if (oap->op_type == OP_APPEND) { - if (oap->block_mode + if (oap->motion_type == MBLOCK && curwin->w_cursor.coladd == 0 ) { /* Move the cursor to the character right of the block. */ @@ -2061,7 +2061,7 @@ void op_insert(oparg_T *oap, long count1) if (curwin->w_cursor.lnum != oap->start.lnum || got_int) return; - if (oap->block_mode) { + if (oap->motion_type == MBLOCK) { struct block_def bd2; /* The user may have moved the cursor before inserting something, try @@ -2166,13 +2166,14 @@ int op_change(oparg_T *oap) && !virtual_op) inc_cursor(); - /* check for still on same line (<CR> in inserted text meaningless) */ - /* skip blank lines too */ - if (oap->block_mode) { - /* Add spaces before getting the current line length. */ + // check for still on same line (<CR> in inserted text meaningless) + // skip blank lines too + if (oap->motion_type == MBLOCK) { + // Add spaces before getting the current line length. if (virtual_op && (curwin->w_cursor.coladd > 0 - || gchar_cursor() == NUL)) + || gchar_cursor() == NUL)) { coladvance_force(getviscol()); + } firstline = ml_get(oap->start.lnum); pre_textlen = (long)STRLEN(firstline); pre_indent = (long)(skipwhite(firstline) - firstline); @@ -2189,9 +2190,10 @@ int op_change(oparg_T *oap) * block. * Don't repeat the insert when Insert mode ended with CTRL-C. */ - if (oap->block_mode && oap->start.lnum != oap->end.lnum && !got_int) { - /* Auto-indenting may have changed the indent. If the cursor was past - * the indent, exclude that indent change from the inserted text. */ + if (oap->motion_type == MBLOCK + && oap->start.lnum != oap->end.lnum && !got_int) { + // Auto-indenting may have changed the indent. If the cursor was past + // the indent, exclude that indent change from the inserted text. firstline = ml_get(oap->start.lnum); if (bd.textcol > (colnr_T)pre_indent) { long new_indent = (long)(skipwhite(firstline) - firstline); @@ -2332,13 +2334,12 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) * If the cursor was in column 1 before and after the movement, and the * operator is not inclusive, the yank is always linewise. */ - if ( oap->motion_type == MCHAR - && oap->start.col == 0 - && !oap->inclusive - && (!oap->is_VIsual || *p_sel == 'o') - && !oap->block_mode - && oap->end.col == 0 - && yanklines > 1) { + if (oap->motion_type == MCHAR + && oap->start.col == 0 + && !oap->inclusive + && (!oap->is_VIsual || *p_sel == 'o') + && oap->end.col == 0 + && yanklines > 1) { yanktype = MLINE; --yankendlnum; --yanklines; @@ -2354,9 +2355,8 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) y_idx = 0; lnum = oap->start.lnum; - if (oap->block_mode) { - /* Visual block mode */ - reg->y_type = MBLOCK; /* set the yank register type */ + if (yanktype == MBLOCK) { + // Visual block mode reg->y_width = oap->end_vcol - oap->start_vcol; if (curwin->w_curswant == MAXCOL && reg->y_width > 0) @@ -2470,25 +2470,26 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) if (curwin->w_p_rnu) { redraw_later(SOME_VALID); // cursor moved to start } - if (message) { /* Display message about yank? */ - if (yanktype == MCHAR - && !oap->block_mode - && yanklines == 1) + if (message) { // Display message about yank? + if (yanktype == MCHAR && yanklines == 1) { yanklines = 0; - /* Some versions of Vi use ">=" here, some don't... */ + } + // Some versions of Vi use ">=" here, some don't... if (yanklines > p_report) { - /* redisplay now, so message is not deleted */ + // redisplay now, so message is not deleted update_topline_redraw(); if (yanklines == 1) { - if (oap->block_mode) + if (yanktype == MBLOCK) { MSG(_("block of 1 line yanked")); - else + } else { MSG(_("1 line yanked")); - } else if (oap->block_mode) + } + } else if (yanktype == MBLOCK) { smsg(_("block of %" PRId64 " lines yanked"), (int64_t)yanklines); - else + } else { smsg(_("%" PRId64 " lines yanked"), (int64_t)yanklines); + } } } @@ -2497,9 +2498,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) */ curbuf->b_op_start = oap->start; curbuf->b_op_end = oap->end; - if (yanktype == MLINE - && !oap->block_mode - ) { + if (yanktype == MLINE) { curbuf->b_op_start.col = 0; curbuf->b_op_end.col = MAXCOL; } @@ -4658,6 +4657,27 @@ void write_reg_contents_ex(int name, return; } + if (name == '#') { + buf_T *buf; + + if (ascii_isdigit(*str)) { + int num = atoi((char *)str); + + buf = buflist_findnr(num); + if (buf == NULL) { + EMSGN(_(e_nobufnr), (long)num); + } + } else { + buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), + true, false, false)); + } + if (buf == NULL) { + return; + } + curwin->w_alt_fnum = buf->b_fnum; + return; + } + if (name == '=') { size_t offset = 0; size_t totlen = (size_t) len; @@ -4903,7 +4923,7 @@ void cursor_pos_info(void) /* Make 'sbr' empty for a moment to get the correct size. */ p_sbr = empty_option; oparg.is_VIsual = true; - oparg.block_mode = true; + oparg.motion_type = MBLOCK; oparg.op_type = OP_NOP; getvcols(curwin, &min_pos, &max_pos, &oparg.start_vcol, &oparg.end_vcol); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index c72e1cf0bb..938aa9bc83 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -405,27 +405,25 @@ static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent", # define FDO_INSERT 0x100 # define FDO_UNDO 0x200 # define FDO_JUMP 0x400 -EXTERN char_u *p_fp; /* 'formatprg' */ -#ifdef HAVE_FSYNC -EXTERN int p_fs; /* 'fsync' */ -#endif -EXTERN int p_gd; /* 'gdefault' */ -EXTERN char_u *p_pdev; /* 'printdevice' */ -EXTERN char_u *p_penc; /* 'printencoding' */ -EXTERN char_u *p_pexpr; /* 'printexpr' */ -EXTERN char_u *p_pmfn; /* 'printmbfont' */ -EXTERN char_u *p_pmcs; /* 'printmbcharset' */ -EXTERN char_u *p_pfn; /* 'printfont' */ -EXTERN char_u *p_popt; /* 'printoptions' */ -EXTERN char_u *p_header; /* 'printheader' */ -EXTERN int p_prompt; /* 'prompt' */ -EXTERN char_u *p_guicursor; /* 'guicursor' */ -EXTERN char_u *p_hf; /* 'helpfile' */ -EXTERN long p_hh; /* 'helpheight' */ -EXTERN char_u *p_hlg; /* 'helplang' */ -EXTERN int p_hid; /* 'hidden' */ -/* Use P_HID to check if a buffer is to be hidden when it is no longer - * visible in a window. */ +EXTERN char_u *p_fp; // 'formatprg' +EXTERN int p_fs; // 'fsync' +EXTERN int p_gd; // 'gdefault' +EXTERN char_u *p_pdev; // 'printdevice' +EXTERN char_u *p_penc; // 'printencoding' +EXTERN char_u *p_pexpr; // 'printexpr' +EXTERN char_u *p_pmfn; // 'printmbfont' +EXTERN char_u *p_pmcs; // 'printmbcharset' +EXTERN char_u *p_pfn; // 'printfont' +EXTERN char_u *p_popt; // 'printoptions' +EXTERN char_u *p_header; // 'printheader' +EXTERN int p_prompt; // 'prompt' +EXTERN char_u *p_guicursor; // 'guicursor' +EXTERN char_u *p_hf; // 'helpfile' +EXTERN long p_hh; // 'helpheight' +EXTERN char_u *p_hlg; // 'helplang' +EXTERN int p_hid; // 'hidden' +// Use P_HID to check if a buffer is to be hidden when it is no longer +// visible in a window. # define P_HID(buf) (buf_hide(buf)) EXTERN char_u *p_hl; /* 'highlight' */ EXTERN int p_hls; /* 'hlsearch' */ diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 5187340629..e485b90394 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -959,7 +959,6 @@ return { type='bool', scope={'global'}, secure=true, vi_def=true, - enable_if='HAVE_FSYNC', varname='p_fs', defaults={if_true={vi=true}} }, diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index d59b66e773..1a4c3495f2 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -202,6 +202,19 @@ int os_open(const char* path, int flags, int mode) return r; } +/// Flushes file modifications to disk. +/// +/// @param fd the file descriptor of the file to flush to disk. +/// +/// @return `0` on success, a libuv error code on failure. +int os_fsync(int fd) +{ + uv_fs_t fsync_req; + int r = uv_fs_fsync(&fs_loop, &fsync_req, fd, NULL); + uv_fs_req_cleanup(&fsync_req); + return r; +} + /// Get stat information for a file. /// /// @return libuv return code. diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 637a86c74f..8ebb7562ef 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -42,17 +42,17 @@ int os_get_usernames(garray_T *users) int os_get_user_name(char *s, size_t len) { #ifdef UNIX - return os_get_uname(getuid(), s, len); + return os_get_uname((uv_uid_t)getuid(), s, len); #else // TODO(equalsraf): Windows GetUserName() - return os_get_uname(0, s, len); + return os_get_uname((uv_uid_t)0, s, len); #endif } // Insert user name for "uid" in s[len]. // Return OK if a name found. // If the name is not found, write the uid into s[len] and return FAIL. -int os_get_uname(uid_t uid, char *s, size_t len) +int os_get_uname(uv_uid_t uid, char *s, size_t len) { #if defined(HAVE_PWD_H) && defined(HAVE_GETPWUID) struct passwd *pw; diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 42e514aa95..6a30472a7c 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -761,9 +761,9 @@ static void close_sd_writer(ShaDaWriteDef *const sd_writer) FUNC_ATTR_NONNULL_ALL { const int fd = (int)(intptr_t) sd_writer->cookie; - if (fsync(fd) < 0) { + if (os_fsync(fd) < 0) { emsg2(_(SERR "System error while synchronizing ShaDa file: %s"), - strerror(errno)); + os_strerror(errno)); errno = 0; } close_file(fd); diff --git a/src/nvim/version.c b/src/nvim/version.c index 39d5b0f1b0..0d8afc4e53 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -466,7 +466,7 @@ static int included_patches[] = { 608, // 607 NA 606, - // 605, + 605, 604, // 603, 602, |