mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix: set cursorlineopt=number in terminal mode (#15493)
When entering terminal mode, cursorlineopt is no longer entirely disabled. Instead, it's set to `number`. Doing so ensures that users using `set cursorline` combined with `set cursorlineopt=number` have consistent highlighting of the line numbers, instead of this being disabled when entering terminal mode. Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
This commit is contained in:
parent
e06936125a
commit
c61a3865ee
@ -53,7 +53,7 @@ next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode.
|
||||
|
||||
Terminal-mode forces these local options:
|
||||
|
||||
'nocursorline'
|
||||
'cursorlineopt' = number
|
||||
'nocursorcolumn'
|
||||
'scrolloff' = 0
|
||||
'sidescrolloff' = 0
|
||||
@ -171,7 +171,7 @@ program window A terminal window for the executed program. When "run" is
|
||||
|
||||
The current window is used to show the source code. When gdb pauses the
|
||||
source file location will be displayed, if possible. A sign is used to
|
||||
highlight the current position, using highlight group debugPC.
|
||||
highlight the current position, using highlight group debugPC.
|
||||
|
||||
If the buffer in the current window is modified, another window will be opened
|
||||
to display the current gdb position.
|
||||
@ -222,7 +222,7 @@ Put focus on the gdb window and type: >
|
||||
run
|
||||
Vim will start running in the program window. Put focus there and type: >
|
||||
:help gui
|
||||
Gdb will run into the ex_help breakpoint. The source window now shows the
|
||||
Gdb will run into the ex_help breakpoint. The source window now shows the
|
||||
ex_cmds.c file. A red "1 " marker will appear in the signcolumn where the
|
||||
breakpoint was set. The line where the debugger stopped is highlighted. You
|
||||
can now step through the program. You will see the highlighting move as the
|
||||
|
@ -358,11 +358,21 @@ void terminal_enter(void)
|
||||
// Disable these options in terminal-mode. They are nonsense because cursor is
|
||||
// placed at end of buffer to "follow" output. #11072
|
||||
win_T *save_curwin = curwin;
|
||||
int save_w_p_cul = curwin->w_p_cul;
|
||||
bool save_w_p_cul = curwin->w_p_cul;
|
||||
char_u *save_w_p_culopt = NULL;
|
||||
char_u save_w_p_culopt_flags = curwin->w_p_culopt_flags;
|
||||
int save_w_p_cuc = curwin->w_p_cuc;
|
||||
long save_w_p_so = curwin->w_p_so;
|
||||
long save_w_p_siso = curwin->w_p_siso;
|
||||
curwin->w_p_cul = false;
|
||||
if (curwin->w_p_cul && curwin->w_p_culopt_flags & CULOPT_NBR) {
|
||||
if (strcmp((char *)curwin->w_p_culopt, "number")) {
|
||||
save_w_p_culopt = curwin->w_p_culopt;
|
||||
curwin->w_p_culopt = (char_u *)xstrdup("number");
|
||||
}
|
||||
curwin->w_p_culopt_flags = CULOPT_NBR;
|
||||
} else {
|
||||
curwin->w_p_cul = false;
|
||||
}
|
||||
curwin->w_p_cuc = false;
|
||||
curwin->w_p_so = 0;
|
||||
curwin->w_p_siso = 0;
|
||||
@ -386,9 +396,16 @@ void terminal_enter(void)
|
||||
|
||||
if (save_curwin == curwin) { // save_curwin may be invalid (window closed)!
|
||||
curwin->w_p_cul = save_w_p_cul;
|
||||
if (save_w_p_culopt) {
|
||||
xfree(curwin->w_p_culopt);
|
||||
curwin->w_p_culopt = save_w_p_culopt;
|
||||
}
|
||||
curwin->w_p_culopt_flags = save_w_p_culopt_flags;
|
||||
curwin->w_p_cuc = save_w_p_cuc;
|
||||
curwin->w_p_so = save_w_p_so;
|
||||
curwin->w_p_siso = save_w_p_siso;
|
||||
} else if (save_w_p_culopt) {
|
||||
xfree(save_w_p_culopt);
|
||||
}
|
||||
|
||||
// draw the unfocused cursor
|
||||
|
@ -22,14 +22,28 @@ describe(':terminal buffer', function()
|
||||
|
||||
it('terminal-mode forces various options', function()
|
||||
feed([[<C-\><C-N>]])
|
||||
command('setlocal cursorline cursorcolumn scrolloff=4 sidescrolloff=7')
|
||||
eq({ 1, 1, 4, 7 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
|
||||
command('setlocal cursorline cursorlineopt=both cursorcolumn scrolloff=4 sidescrolloff=7')
|
||||
eq({ 'both', 1, 1, 4, 7 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
|
||||
eq('n', eval('mode()'))
|
||||
|
||||
-- Enter terminal-mode ("insert" mode in :terminal).
|
||||
feed('i')
|
||||
eq('t', eval('mode()'))
|
||||
eq({ 0, 0, 0, 0 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
|
||||
eq({ 'number', 1, 0, 0, 0 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
|
||||
end)
|
||||
|
||||
it('terminal-mode does not change cursorlineopt if cursorline is disabled', function()
|
||||
feed([[<C-\><C-N>]])
|
||||
command('setlocal nocursorline cursorlineopt=both')
|
||||
feed('i')
|
||||
eq({ 0, 'both' }, eval('[&l:cursorline, &l:cursorlineopt]'))
|
||||
end)
|
||||
|
||||
it('terminal-mode disables cursorline when cursorlineopt is only set to "line', function()
|
||||
feed([[<C-\><C-N>]])
|
||||
command('setlocal cursorline cursorlineopt=line')
|
||||
feed('i')
|
||||
eq({ 0, 'line' }, eval('[&l:cursorline, &l:cursorlineopt]'))
|
||||
end)
|
||||
|
||||
describe('when a new file is edited', function()
|
||||
|
Loading…
Reference in New Issue
Block a user