mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
vim-patch:9.0.0511: unnecessary scrolling for message of only one line (#20261)
Problem: Unnecessary scrolling for message of only one line.
Solution: Only set msg_scroll when needed. (closes vim/vim#11178)
bdedd2bcce
This commit is contained in:
@@ -596,10 +596,10 @@ void msg_source(int attr)
|
|||||||
}
|
}
|
||||||
recursive = true;
|
recursive = true;
|
||||||
|
|
||||||
msg_scroll = true; // this will take more than one line
|
|
||||||
no_wait_return++;
|
no_wait_return++;
|
||||||
char *p = get_emsg_source();
|
char *p = get_emsg_source();
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
|
msg_scroll = true; // this will take more than one line
|
||||||
msg_attr(p, attr);
|
msg_attr(p, attr);
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
@@ -739,7 +739,7 @@ static bool emsg_multiline(const char *s, bool multiline)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display name and line number for the source of the error.
|
// Display name and line number for the source of the error.
|
||||||
// Sets "msg_scroll".
|
msg_scroll = true;
|
||||||
msg_source(attr);
|
msg_source(attr);
|
||||||
|
|
||||||
// Display the error message itself.
|
// Display the error message itself.
|
||||||
|
@@ -171,6 +171,38 @@ func Test_echospace()
|
|||||||
set ruler& showcmd&
|
set ruler& showcmd&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_warning_scroll()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
let lines =<< trim END
|
||||||
|
call test_override('ui_delay', 50)
|
||||||
|
set noruler
|
||||||
|
set readonly
|
||||||
|
undo
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XTestWarningScroll', 'D')
|
||||||
|
let buf = RunVimInTerminal('', #{rows: 8})
|
||||||
|
|
||||||
|
" When the warning comes from a script, messages are scrolled so that the
|
||||||
|
" stacktrace is visible.
|
||||||
|
call term_sendkeys(buf, ":source XTestWarningScroll\n")
|
||||||
|
" only match the final colon in the line that shows the source
|
||||||
|
call WaitForAssert({-> assert_match(':$', term_getline(buf, 5))})
|
||||||
|
call WaitForAssert({-> assert_equal('line 4:W10: Warning: Changing a readonly file', term_getline(buf, 6))})
|
||||||
|
call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 7))})
|
||||||
|
call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 8))})
|
||||||
|
call term_sendkeys(buf, "\n")
|
||||||
|
|
||||||
|
" When the warning does not come from a script, messages are not scrolled.
|
||||||
|
call term_sendkeys(buf, ":enew\n")
|
||||||
|
call term_sendkeys(buf, ":set readonly\n")
|
||||||
|
call term_sendkeys(buf, 'u')
|
||||||
|
call WaitForAssert({-> assert_equal('W10: Warning: Changing a readonly file', term_getline(buf, 8))})
|
||||||
|
call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 8))})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test more-prompt (see :help more-prompt).
|
" Test more-prompt (see :help more-prompt).
|
||||||
func Test_message_more()
|
func Test_message_more()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
@@ -10,6 +10,43 @@ before_each(clear)
|
|||||||
describe('messages', function()
|
describe('messages', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
|
-- oldtest: Test_warning_scroll()
|
||||||
|
it('a warning causes scrolling if and only if it has a stacktrace', function()
|
||||||
|
screen = Screen.new(75, 6)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||||
|
[1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
|
||||||
|
[2] = {bold = true, reverse = true}, -- MsgSeparator
|
||||||
|
[3] = {foreground = Screen.colors.Red}, -- WarningMsg
|
||||||
|
})
|
||||||
|
screen:attach()
|
||||||
|
|
||||||
|
-- When the warning comes from a script, messages are scrolled so that the
|
||||||
|
-- stacktrace is visible.
|
||||||
|
-- It is a bit hard to assert the screen when sourcing a script, so skip this part.
|
||||||
|
|
||||||
|
-- When the warning does not come from a script, messages are not scrolled.
|
||||||
|
command('enew')
|
||||||
|
command('set readonly')
|
||||||
|
feed('u')
|
||||||
|
screen:expect({grid = [[
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:W10: Warning: Changing a readonly file}^ |
|
||||||
|
]], timeout = 500})
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
Already at oldest change |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
describe('more prompt', function()
|
describe('more prompt', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
screen = Screen.new(75, 6)
|
screen = Screen.new(75, 6)
|
||||||
|
Reference in New Issue
Block a user