mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1542: line not fully displayed if it doesn't fit in the screen
Problem: Line not fully displayed if it doesn't fit in the screen.
Solution: Do not reset s_skipcol if not needed. (Luuk van Baal,
closes vim/vim#12376)
6c018680be
This commit is contained in:
parent
d5780e133a
commit
15c684b358
@ -2090,10 +2090,9 @@ void scroll_cursor_halfway(bool atend, bool prefer_above)
|
|||||||
colnr_T skipcol = 0;
|
colnr_T skipcol = 0;
|
||||||
|
|
||||||
int want_height;
|
int want_height;
|
||||||
bool smooth_scroll = false;
|
bool do_sms = curwin->w_p_wrap && curwin->w_p_sms;
|
||||||
if (curwin->w_p_sms && curwin->w_p_wrap) {
|
if (do_sms) {
|
||||||
// 'smoothscroll' and 'wrap' are set
|
// 'smoothscroll' and 'wrap' are set
|
||||||
smooth_scroll = true;
|
|
||||||
if (atend) {
|
if (atend) {
|
||||||
want_height = (curwin->w_height_inner - used) / 2;
|
want_height = (curwin->w_height_inner - used) / 2;
|
||||||
used = 0;
|
used = 0;
|
||||||
@ -2106,7 +2105,7 @@ void scroll_cursor_halfway(bool atend, bool prefer_above)
|
|||||||
while (topline > 1) {
|
while (topline > 1) {
|
||||||
// If using smoothscroll, we can precisely scroll to the
|
// If using smoothscroll, we can precisely scroll to the
|
||||||
// exact point where the cursor is halfway down the screen.
|
// exact point where the cursor is halfway down the screen.
|
||||||
if (smooth_scroll) {
|
if (do_sms) {
|
||||||
topline_back_winheight(curwin, &loff, false);
|
topline_back_winheight(curwin, &loff, false);
|
||||||
if (loff.height == MAXCOL) {
|
if (loff.height == MAXCOL) {
|
||||||
break;
|
break;
|
||||||
@ -2190,7 +2189,7 @@ void scroll_cursor_halfway(bool atend, bool prefer_above)
|
|||||||
if (skipcol != 0) {
|
if (skipcol != 0) {
|
||||||
curwin->w_skipcol = skipcol;
|
curwin->w_skipcol = skipcol;
|
||||||
redraw_later(curwin, UPD_NOT_VALID);
|
redraw_later(curwin, UPD_NOT_VALID);
|
||||||
} else {
|
} else if (do_sms) {
|
||||||
reset_skipcol(curwin);
|
reset_skipcol(curwin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ describe('display', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- oldtest: Test_display_long_lastline()
|
-- oldtest: Test_display_long_lastline()
|
||||||
it('display "lastline" shows correct text when end of wrapped line is deleted', function()
|
it('"lastline" shows correct text when end of wrapped line is deleted', function()
|
||||||
local screen = Screen.new(35, 14)
|
local screen = Screen.new(35, 14)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
exec([[
|
exec([[
|
||||||
@ -241,4 +241,24 @@ describe('display', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_display_cursor_long_line()
|
||||||
|
it("correctly shows line that doesn't fit in the window", function()
|
||||||
|
local screen = Screen.new(75, 8)
|
||||||
|
screen:attach()
|
||||||
|
exec([[
|
||||||
|
call setline(1, ['a', 'bbbbb '->repeat(100), 'c'])
|
||||||
|
norm $j
|
||||||
|
]])
|
||||||
|
screen:expect([[
|
||||||
|
<<<bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb |
|
||||||
|
bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbb|
|
||||||
|
bb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb |
|
||||||
|
bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbb|
|
||||||
|
bb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb |
|
||||||
|
bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbb|
|
||||||
|
bb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb^ |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -500,4 +500,22 @@ func Test_display_long_lastline()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Moving the cursor to a line that doesn't fit in the window should show
|
||||||
|
" correctly.
|
||||||
|
func Test_display_cursor_long_line()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, ['a', 'bbbbb '->repeat(100), 'c'])
|
||||||
|
norm $j
|
||||||
|
END
|
||||||
|
|
||||||
|
call writefile(lines, 'XdispCursorLongline', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S XdispCursorLongline', #{rows: 8})
|
||||||
|
|
||||||
|
call VerifyScreenDump(buf, 'Test_display_cursor_long_line', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user