Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 894f6be

Browse filesBrowse files
mrbiggfootjustinmk
authored andcommitted
:terminal : set topline based on window height #8325
closes #8324 closes #8556
1 parent 28f87c5 commit 894f6be
Copy full SHA for 894f6be

File tree

Expand file treeCollapse file tree

11 files changed

+31
-16
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+31
-16
lines changed

‎src/nvim/buffer_defs.h

Copy file name to clipboardExpand all lines: src/nvim/buffer_defs.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ struct window_S {
10631063
int w_width; /* Width of window, excluding separation. */
10641064
int w_vsep_width; /* Number of separator columns (0 or 1). */
10651065

1066-
// inner size of window, which can be overriden by external UI
1066+
// inner size of window, which can be overridden by external UI
10671067
int w_height_inner;
10681068
int w_width_inner;
10691069
// external UI request. If non-zero, the inner size will use this.

‎src/nvim/terminal.c

Copy file name to clipboardExpand all lines: src/nvim/terminal.c
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,6 @@ static void redraw(bool restore_cursor)
13111311

13121312
static void adjust_topline(Terminal *term, buf_T *buf, long added)
13131313
{
1314-
int height, width;
1315-
vterm_get_size(term->vt, &height, &width);
13161314
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
13171315
if (wp->w_buffer == buf) {
13181316
linenr_T ml_end = buf->b_ml.ml_line_count;
@@ -1321,7 +1319,7 @@ static void adjust_topline(Terminal *term, buf_T *buf, long added)
13211319
if (following || (wp == curwin && is_focused(term))) {
13221320
// "Follow" the terminal output
13231321
wp->w_cursor.lnum = ml_end;
1324-
set_topline(wp, MAX(wp->w_cursor.lnum - height + 1, 1));
1322+
set_topline(wp, MAX(wp->w_cursor.lnum - wp->w_height_inner + 1, 1));
13251323
} else {
13261324
// Ensure valid cursor for each window displaying this terminal.
13271325
wp->w_cursor.lnum = MIN(wp->w_cursor.lnum, ml_end);

‎test/functional/terminal/altscreen_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/altscreen_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local exit_altscreen = thelpers.exit_altscreen
88

99
if helpers.pending_win32(pending) then return end
1010

11-
describe('terminal altscreen', function()
11+
describe(':terminal altscreen', function()
1212
local screen
1313

1414
before_each(function()

‎test/functional/terminal/buffer_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/buffer_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.s
66
local eq, neq = helpers.eq, helpers.neq
77
local write_file = helpers.write_file
88

9-
describe('terminal buffer', function()
9+
describe(':terminal buffer', function()
1010
local screen
1111

1212
before_each(function()

‎test/functional/terminal/cursor_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/cursor_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local feed_command = helpers.feed_command
77
local hide_cursor = thelpers.hide_cursor
88
local show_cursor = thelpers.show_cursor
99

10-
describe('terminal cursor', function()
10+
describe(':terminal cursor', function()
1111
local screen
1212

1313
before_each(function()

‎test/functional/terminal/highlight_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/highlight_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
55
local nvim_dir, command = helpers.nvim_dir, helpers.command
66
local eq, eval = helpers.eq, helpers.eval
77

8-
describe('terminal window highlighting', function()
8+
describe(':terminal window highlighting', function()
99
local screen
1010

1111
before_each(function()

‎test/functional/terminal/mouse_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/mouse_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
44
local feed, nvim = helpers.feed, helpers.nvim
55
local feed_data = thelpers.feed_data
66

7-
describe('terminal mouse', function()
7+
describe(':terminal mouse', function()
88
local screen
99

1010
before_each(function()

‎test/functional/terminal/scrollback_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/scrollback_spec.lua
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ local curbufmeths = helpers.curbufmeths
1212
local nvim = helpers.nvim
1313
local feed_data = thelpers.feed_data
1414

15-
describe('terminal scrollback', function()
15+
describe(':terminal scrollback', function()
1616
local screen
1717

1818
before_each(function()
@@ -344,7 +344,7 @@ describe('terminal scrollback', function()
344344
end)
345345
end)
346346

347-
describe('terminal prints more lines than the screen height and exits', function()
347+
describe(':terminal prints more lines than the screen height and exits', function()
348348
it('will push extra lines to scrollback', function()
349349
clear()
350350
local screen = Screen.new(30, 7)
@@ -460,7 +460,7 @@ describe("'scrollback' option", function()
460460
screen:detach()
461461
end)
462462

463-
it('defaults to 10000 in terminal buffers', function()
463+
it('defaults to 10000 in :terminal buffers', function()
464464
set_fake_shell()
465465
command('terminal')
466466
eq(10000, curbufmeths.get_option('scrollback'))

‎test/functional/terminal/tui_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/tui_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local read_file = helpers.read_file
2020

2121
if helpers.pending_win32(pending) then return end
2222

23-
describe('tui', function()
23+
describe('TUI', function()
2424
local screen
2525

2626
before_each(function()

‎test/functional/terminal/window_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/window_spec.lua
+19-2Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,32 @@ local thelpers = require('test.functional.terminal.helpers')
33
local feed, clear = helpers.feed, helpers.clear
44
local wait = helpers.wait
55
local iswin = helpers.iswin
6+
local command = helpers.command
7+
local retry = helpers.retry
8+
local eq = helpers.eq
9+
local eval = helpers.eval
610

7-
describe('terminal window', function()
11+
describe(':terminal window', function()
812
local screen
913

1014
before_each(function()
1115
clear()
1216
screen = thelpers.screen_setup()
1317
end)
1418

19+
it('sets topline correctly #8556', function()
20+
-- Test has hardcoded assumptions of dimensions.
21+
eq(7, eval('&lines'))
22+
command('set shell=sh')
23+
command('terminal')
24+
retry(nil, nil, function() assert(nil ~= eval('b:terminal_job_pid')) end)
25+
-- Terminal/shell contents must exceed the height of this window.
26+
command('topleft 1split')
27+
feed([[i<cr>]])
28+
-- Check topline _while_ in terminal-mode.
29+
retry(nil, nil, function() eq(6, eval('winsaveview()["topline"]')) end)
30+
end)
31+
1532
describe("with 'number'", function()
1633
it('wraps text', function()
1734
feed([[<C-\><C-N>]])
@@ -124,7 +141,7 @@ describe('terminal window', function()
124141
end)
125142
end)
126143

127-
describe('terminal window with multigrid', function()
144+
describe(':terminal with multigrid', function()
128145
local screen
129146

130147
before_each(function()

‎test/functional/terminal/window_split_tab_spec.lua

Copy file name to clipboardExpand all lines: test/functional/terminal/window_split_tab_spec.lua
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ local eval = helpers.eval
99
local iswin = helpers.iswin
1010
local retry = helpers.retry
1111

12-
describe('terminal', function()
12+
describe(':terminal', function()
1313
local screen
1414

1515
before_each(function()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.