From a021b30edef84bb6fbdbf0b9e045148eb1d20396 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 Sep 2018 19:08:35 -0400 Subject: vim-patch:8.1.0034: cursor not restored with ":edit #" Problem: Cursor not restored with ":edit #". Solution: Don't assume autocommands moved the cursor when it was moved to the first non-blank. https://github.com/vim/vim/commit/adb8fbec4f4059d214fe6acf2485ffd35e803450 --- src/nvim/ex_cmds.c | 14 ++++++++++---- src/nvim/testdir/test_edit.vim | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ac5b3af459..b700d780c7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2546,11 +2546,17 @@ int do_ecmd( } check_arg_idx(curwin); - // If autocommands change the cursor position or topline, we should keep - // it. Also when it moves within a line. + // If autocommands change the cursor position or topline, we should + // keep it. Also when it moves within a line. But not when it moves + // to the first non-blank. if (!equalpos(curwin->w_cursor, orig_pos)) { - newlnum = curwin->w_cursor.lnum; - newcol = curwin->w_cursor.col; + const char_u *text = get_cursor_line_ptr(); + + if (curwin->w_cursor.lnum != orig_pos.lnum + || curwin->w_cursor.col != (int)(skipwhite(text) - text)) { + newlnum = curwin->w_cursor.lnum; + newcol = curwin->w_cursor.col; + } } if (curwin->w_topline == topline) topline = 0; diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 1effc8e12f..989adfce8f 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1390,3 +1390,18 @@ func Test_edit_complete_very_long_name() endif set swapfile& endfunc + +func Test_edit_alt() + " Keeping the cursor line didn't happen when the first line has indent. + new + call setline(1, [' one', 'two', 'three']) + w XAltFile + $ + call assert_equal(3, line('.')) + e Xother + e # + call assert_equal(3, line('.')) + + bwipe XAltFile + call delete('XAltFile') +endfunc -- cgit From 8a845ab3efd87e3c49e4b756a0e74f8e06303fb1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 Sep 2018 22:39:15 -0400 Subject: vim-patch:8.1.0219: expanding ## fails to escape backtick Problem: Expanding ## fails to escape backtick. Solution: Escape a backtick in a file name. (closes vim/vim#3257) https://github.com/vim/vim/commit/2c8c681bfcd5138a0ec8ce018216dc2dc69a11a0 --- src/nvim/ex_docmd.c | 2 +- src/nvim/testdir/test_edit.vim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 03f1446265..6586d82fae 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8735,7 +8735,7 @@ static char_u *arg_all(void) #ifndef BACKSLASH_IN_FILENAME || *p == '\\' #endif - ) { + || *p == '`') { // insert a backslash if (retval != NULL) { retval[len] = '\\'; diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 989adfce8f..b1fce07f39 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1338,6 +1338,14 @@ func! Test_edit_rightleft() bw! endfunc +func Test_edit_backtick() + next a\`b c + call assert_equal('a`b', expand('%')) + next + call assert_equal('c', expand('%')) + call assert_equal('a\`b c', expand('##')) +endfunc + func Test_edit_quit() edit foo.txt split -- cgit From 38c52c63accab5ea2a76bebaa5ccd5a089fa17ab Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 Sep 2018 23:00:12 -0400 Subject: vim-patch:8.0.1809: various typos Problem: Various typos. Solution: Correct the mistakes, change "cursur" to "cursor". (closes vim/vim#2887) https://github.com/vim/vim/commit/b9464821901623f983528acaed9e4dc2cea7387b --- src/nvim/edit.c | 2 +- src/nvim/normal.c | 4 ++-- src/nvim/screen.c | 2 +- src/nvim/ui.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 53fe164050..d0994d35f5 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -298,7 +298,7 @@ static void insert_enter(InsertState *s) // Check if the cursor line needs redrawing before changing State. If // 'concealcursor' is "n" it needs to be redrawn without concealing. - conceal_check_cursur_line(); + conceal_check_cursor_line(); // When doing a paste with the middle mouse button, Insstart is set to // where the paste started. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 09444ace0f..65cc7d1db8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6497,7 +6497,7 @@ void may_start_select(int c) static void n_start_visual_mode(int c) { /* Check for redraw before changing the state. */ - conceal_check_cursur_line(); + conceal_check_cursor_line(); VIsual_mode = c; VIsual_active = true; @@ -6515,7 +6515,7 @@ static void n_start_visual_mode(int c) setmouse(); /* Check for redraw after changing the state. */ - conceal_check_cursur_line(); + conceal_check_cursor_line(); if (p_smd && msg_silent == 0) redraw_cmdline = true; /* show visual mode later */ diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 8ad2145400..36942a1e78 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -478,7 +478,7 @@ int conceal_cursor_line(win_T *wp) /* * Check if the cursor line needs to be redrawn because of 'concealcursor'. */ -void conceal_check_cursur_line(void) +void conceal_check_cursor_line(void) { if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) { need_cursor_line_redraw = TRUE; diff --git a/src/nvim/ui.c b/src/nvim/ui.c index e291111f82..87101c3b64 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -393,7 +393,7 @@ void ui_cursor_shape(void) mode_idx = new_mode_idx; pending_mode_update = true; } - conceal_check_cursur_line(); + conceal_check_cursor_line(); } /// Returns true if `widget` is externalized. -- cgit From e15c34fbc29b4d98566f80a0d65436081a32e5b5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 Sep 2018 23:04:54 -0400 Subject: lint --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 65cc7d1db8..217bf4f876 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6496,7 +6496,7 @@ void may_start_select(int c) */ static void n_start_visual_mode(int c) { - /* Check for redraw before changing the state. */ + // Check for redraw before changing the state. conceal_check_cursor_line(); VIsual_mode = c; @@ -6514,7 +6514,7 @@ static void n_start_visual_mode(int c) foldAdjustVisual(); setmouse(); - /* Check for redraw after changing the state. */ + // Check for redraw after changing the state. conceal_check_cursor_line(); if (p_smd && msg_silent == 0) -- cgit