diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-11 20:12:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 20:12:58 +0800 |
commit | 8065fc9aaeff734f38109aec52bf852379a5a183 (patch) | |
tree | c8c98e46cb261ce7d065d197c32676ff69ea2296 | |
parent | f3efcd0348d34e4ebb44bde3be310379fb84a5a9 (diff) | |
download | rneovim-8065fc9aaeff734f38109aec52bf852379a5a183.tar.gz rneovim-8065fc9aaeff734f38109aec52bf852379a5a183.tar.bz2 rneovim-8065fc9aaeff734f38109aec52bf852379a5a183.zip |
fix(edit): don't subtract msg_scrolled when removing double quote (#22630)
With msg_grid there is no need to subtract msg_scrolled.
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | test/functional/editor/mode_insert_spec.lua | 43 |
2 files changed, 45 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 9eb4802d97..6e8dc8fc02 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1510,14 +1510,14 @@ bool prompt_curpos_editable(void) // Undo the previous edit_putchar(). void edit_unputchar(void) { - if (pc_status != PC_STATUS_UNSET && pc_row >= msg_scrolled) { + if (pc_status != PC_STATUS_UNSET) { if (pc_status == PC_STATUS_RIGHT) { curwin->w_wcol++; } if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) { redrawWinline(curwin, curwin->w_cursor.lnum); } else { - grid_puts(&curwin->w_grid, pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr); + grid_puts(&curwin->w_grid, pc_bytes, pc_row, pc_col, pc_attr); } } } diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index cd51a65be3..b00661ac3a 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -1,6 +1,7 @@ -- Insert-mode tests. local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local expect = helpers.expect local command = helpers.command @@ -48,6 +49,48 @@ describe('insert-mode', function() feed('i<C-r>"') expect('påskägg') end) + + it('double quote is removed after hit-enter prompt #22609', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, + [1] = {foreground = Screen.colors.Blue}, + [2] = {foreground = Screen.colors.SlateBlue}, + [3] = {bold = true}, + [4] = {reverse = true, bold = true}, + [5] = {background = Screen.colors.Red, foreground = Screen.colors.Red}, + [6] = {background = Screen.colors.Red, foreground = Screen.colors.White}, + [7] = {foreground = Screen.colors.SeaGreen, bold = true}, + }) + screen:attach() + feed('i<C-R>') + screen:expect([[ + {1:^"} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + feed('={}<CR>') + screen:expect([[ + {1:"} | + {0:~ }| + {4: }| + ={5:{}{2:}} | + {6:E731: using Dictionary as a String} | + {7:Press ENTER or type command to continue}^ | + ]]) + feed('<CR>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end) end) describe('Ctrl-O', function() |