summaryrefslogtreecommitdiffstats
path: root/src/normal.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 07:39:41 +0000
commit00c068502d170f9f9b59c4a68aa12e8835859f6c (patch)
tree2047fc01b8c70326d9b87b47a575e7e5f2141b62 /src/normal.c
parentAdding upstream version 2:9.1.0016. (diff)
downloadvim-00c068502d170f9f9b59c4a68aa12e8835859f6c.tar.xz
vim-00c068502d170f9f9b59c4a68aa12e8835859f6c.zip
Adding upstream version 2:9.1.0199.upstream/2%9.1.0199
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/normal.c b/src/normal.c
index fd89b00..5ef3a92 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -568,10 +568,10 @@ normal_cmd_get_more_chars(
++no_mapping;
// Vim may be in a different mode when the user types the next key,
// but when replaying a recording the next key is already in the
- // typeahead buffer, so record a <Nop> before that to prevent the
- // vpeekc() above from applying wrong mappings when replaying.
+ // typeahead buffer, so record an <Ignore> before that to prevent
+ // the vpeekc() above from applying wrong mappings when replaying.
++no_u_sync;
- gotchars_nop();
+ gotchars_ignore();
--no_u_sync;
}
}
@@ -3225,8 +3225,7 @@ nv_colon(cmdarg_T *cap)
clearop(cap->oap);
else if (cap->oap->op_type != OP_NOP
&& (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
- || cap->oap->start.col >
- (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
+ || cap->oap->start.col > ml_get_len(cap->oap->start.lnum)
|| did_emsg
))
// The start of the operator has become invalid by the Ex command.
@@ -3675,7 +3674,7 @@ get_visual_text(
if (VIsual_mode == 'V')
{
*pp = ml_get_curline();
- *lenp = (int)STRLEN(*pp);
+ *lenp = (int)ml_get_curline_len();
}
else
{
@@ -4074,6 +4073,9 @@ nv_gotofile(cmdarg_T *cap)
return;
#endif
+ if (!check_can_set_curbuf_disabled())
+ return;
+
ptr = grab_file_name(cap->count1, &lnum);
if (ptr != NULL)
@@ -4476,7 +4478,8 @@ nv_brackets(cmdarg_T *cap)
SAFE_isupper(cap->nchar) ? ACTION_SHOW_ALL :
SAFE_islower(cap->nchar) ? ACTION_SHOW : ACTION_GOTO,
cap->cmdchar == ']' ? curwin->w_cursor.lnum + 1 : (linenr_T)1,
- (linenr_T)MAXLNUM);
+ (linenr_T)MAXLNUM,
+ FALSE);
vim_free(ptr);
curwin->w_set_curswant = TRUE;
}
@@ -4768,7 +4771,6 @@ nv_kundo(cmdarg_T *cap)
static void
nv_replace(cmdarg_T *cap)
{
- char_u *ptr;
int had_ctrl_v;
long n;
@@ -4835,9 +4837,8 @@ nv_replace(cmdarg_T *cap)
}
// Abort if not enough characters to replace.
- ptr = ml_get_cursor();
- if (STRLEN(ptr) < (unsigned)cap->count1
- || (has_mbyte && mb_charlen(ptr) < cap->count1))
+ if ((size_t)ml_get_cursor_len() < (unsigned)cap->count1
+ || (has_mbyte && mb_charlen(ml_get_cursor()) < cap->count1))
{
clearopbeep(cap->oap);
return;
@@ -4917,11 +4918,13 @@ nv_replace(cmdarg_T *cap)
}
else
{
+ char_u *ptr;
+
// Replace the characters within one line.
for (n = cap->count1; n > 0; --n)
{
- // Get ptr again, because u_save and/or showmatch() will have
- // released the line. This may also happen in ins_copychar().
+ // Get ptr again, because ins_copychar() and showmatch()
+ // will have released the line.
// At the same time we let know that the line will be changed.
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
{
@@ -4945,6 +4948,7 @@ nv_replace(cmdarg_T *cap)
if (netbeans_active())
{
colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);
+ ptr = ml_get_curline();
netbeans_removed(curbuf, curwin->w_cursor.lnum, start,
cap->count1);
@@ -5130,7 +5134,7 @@ n_swapchar(cmdarg_T *cap)
if (did_change)
{
ptr = ml_get(pos.lnum);
- count = (int)STRLEN(ptr) - pos.col;
+ count = (int)ml_get_len(pos.lnum) - pos.col;
netbeans_removed(curbuf, pos.lnum, pos.col,
(long)count);
// line may have been flushed, get it again
@@ -5919,7 +5923,7 @@ nv_gi_cmd(cmdarg_T *cap)
{
curwin->w_cursor = curbuf->b_last_insert;
check_cursor_lnum();
- i = (int)STRLEN(ml_get_curline());
+ i = (int)ml_get_curline_len();
if (curwin->w_cursor.col > (colnr_T)i)
{
if (virtual_active())
@@ -6717,7 +6721,7 @@ unadjust_for_sel(void)
else if (pp->lnum > 1)
{
--pp->lnum;
- pp->col = (colnr_T)STRLEN(ml_get(pp->lnum));
+ pp->col = ml_get_len(pp->lnum);
return TRUE;
}
}
@@ -7323,6 +7327,9 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
int dir;
int flags = 0;
int keep_registers = FALSE;
+#ifdef FEAT_FOLDING
+ int save_fen = curwin->w_p_fen;
+#endif
if (cap->oap->op_type != OP_NOP)
{
@@ -7388,6 +7395,12 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
reg1 = get_register(regname, TRUE);
}
+#ifdef FEAT_FOLDING
+ // Temporarily disable folding, as deleting a fold marker may cause
+ // the cursor to be included in a fold.
+ curwin->w_p_fen = FALSE;
+#endif
+
// Now delete the selected text. Avoid messages here.
cap->cmdchar = 'd';
cap->nchar = NUL;
@@ -7435,10 +7448,14 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
if (reg2 != NULL)
put_register(regname, reg2);
- // What to reselect with "gv"? Selecting the just put text seems to
- // be the most useful, since the original text was removed.
if (was_visual)
{
+#ifdef FEAT_FOLDING
+ if (save_fen)
+ curwin->w_p_fen = TRUE;
+#endif
+ // What to reselect with "gv"? Selecting the just put text seems to
+ // be the most useful, since the original text was removed.
curbuf->b_visual.vi_start = curbuf->b_op_start;
curbuf->b_visual.vi_end = curbuf->b_op_end;
// need to adjust cursor position