aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/motion.txt10
-rw-r--r--src/nvim/mark.c5
-rw-r--r--src/nvim/normal.c5
-rw-r--r--src/nvim/testdir/test_marks.vim68
4 files changed, 83 insertions, 5 deletions
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt
index 6f3a585ff3..92af525ecf 100644
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -1271,7 +1271,10 @@ the current line is included. You can then use "%" to go to the matching line.
H To line [count] from top (Home) of window (default:
first line on the window) on the first non-blank
character |linewise|. See also 'startofline' option.
- Cursor is adjusted for 'scrolloff' option.
+ Cursor is adjusted for 'scrolloff' option, unless an
+ operator is pending, in which case the text may
+ scroll. E.g. "yH" yanks from the first visible line
+ until the cursor line (inclusive).
*M*
M To Middle line of window, on the first non-blank
@@ -1281,7 +1284,10 @@ M To Middle line of window, on the first non-blank
L To line [count] from bottom of window (default: Last
line on the window) on the first non-blank character
|linewise|. See also 'startofline' option.
- Cursor is adjusted for 'scrolloff' option.
+ Cursor is adjusted for 'scrolloff' option, unless an
+ operator is pending, in which case the text may
+ scroll. E.g. "yL" yanks from the cursor to the last
+ visible line.
<LeftMouse> Moves to the position on the screen where the mouse
click is |exclusive|. See also |<LeftMouse>|. If the
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 5366fa4b7f..05f78c76bc 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -599,9 +599,10 @@ static char_u *mark_line(pos_T *mp, int lead_len)
if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count)
return vim_strsave((char_u *)"-invalid-");
assert(Columns >= 0 && (size_t)Columns <= SIZE_MAX);
- s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (size_t)Columns);
+ // Allow for up to 5 bytes per character.
+ s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (size_t)Columns * 5);
- /* Truncate the line to fit it in the window */
+ // Truncate the line to fit it in the window
len = 0;
for (p = s; *p != NUL; MB_PTR_ADV(p)) {
len += ptr2cells(p);
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 484a5e41cc..32d9e7e982 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -5042,7 +5042,10 @@ static void nv_scroll(cmdarg_T *cap)
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
}
- cursor_correct(); /* correct for 'so' */
+ // Correct for 'so', except when an operator is pending.
+ if (cap->oap->op_type == OP_NOP) {
+ cursor_correct();
+ }
beginline(BL_SOL | BL_FIX);
}
diff --git a/src/nvim/testdir/test_marks.vim b/src/nvim/testdir/test_marks.vim
index 18a0c71aab..8858cd22b8 100644
--- a/src/nvim/testdir/test_marks.vim
+++ b/src/nvim/testdir/test_marks.vim
@@ -68,3 +68,71 @@ func Test_setpos()
call win_gotoid(twowin)
bwipe!
endfunc
+
+func Test_marks_cmd()
+ new Xone
+ call setline(1, ['aaa', 'bbb'])
+ norm! maG$mB
+ w!
+ new Xtwo
+ call setline(1, ['ccc', 'ddd'])
+ norm! $mcGmD
+ w!
+
+ b Xone
+ let a = split(execute('marks'), "\n")
+ call assert_equal(9, len(a))
+ call assert_equal('mark line col file/text', a[0])
+ call assert_equal(" ' 2 0 bbb", a[1])
+ call assert_equal(' a 1 0 aaa', a[2])
+ call assert_equal(' B 2 2 bbb', a[3])
+ call assert_equal(' D 2 0 Xtwo', a[4])
+ call assert_equal(' " 1 0 aaa', a[5])
+ call assert_equal(' [ 1 0 aaa', a[6])
+ call assert_equal(' ] 2 0 bbb', a[7])
+ call assert_equal(' . 2 0 bbb', a[8])
+
+ b Xtwo
+ let a = split(execute('marks'), "\n")
+ call assert_equal(9, len(a))
+ call assert_equal('mark line col file/text', a[0])
+ call assert_equal(" ' 1 0 ccc", a[1])
+ call assert_equal(' c 1 2 ccc', a[2])
+ call assert_equal(' B 2 2 Xone', a[3])
+ call assert_equal(' D 2 0 ddd', a[4])
+ call assert_equal(' " 2 0 ddd', a[5])
+ call assert_equal(' [ 1 0 ccc', a[6])
+ call assert_equal(' ] 2 0 ddd', a[7])
+ call assert_equal(' . 2 0 ddd', a[8])
+
+ b Xone
+ delmarks aB
+ let a = split(execute('marks aBcD'), "\n")
+ call assert_equal(2, len(a))
+ call assert_equal('mark line col file/text', a[0])
+ call assert_equal(' D 2 0 Xtwo', a[1])
+
+ b Xtwo
+ delmarks cD
+ call assert_fails('marks aBcD', 'E283:')
+
+ call delete('Xone')
+ call delete('Xtwo')
+ %bwipe
+endfunc
+
+func Test_marks_cmd_multibyte()
+ if !has('multi_byte')
+ return
+ endif
+ new Xone
+ call setline(1, [repeat('á', &columns)])
+ norm! ma
+
+ let a = split(execute('marks a'), "\n")
+ call assert_equal(2, len(a))
+ let expected = ' a 1 0 ' . repeat('á', &columns - 16)
+ call assert_equal(expected, a[1])
+
+ bwipe!
+endfunc