aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2024-03-28 15:30:16 +0200
committerEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2024-03-29 11:44:49 +0200
commit9530a23016808fa5587e07d3d335852b90069c0f (patch)
treedb87befc157743e2603e94d1912568fb3fe4abf0
parentb1615a35f08ae3073f7d2e4e8e080907f0d48e92 (diff)
downloadrneovim-9530a23016808fa5587e07d3d335852b90069c0f.tar.gz
rneovim-9530a23016808fa5587e07d3d335852b90069c0f.tar.bz2
rneovim-9530a23016808fa5587e07d3d335852b90069c0f.zip
fix(intro): link showing intro to state at start
Problem: Current behavior of stateful intro message is too persistent. For example, it is still drawn if new empty buffer is shown in current window (either by explicitly setting it or after `tabnew`). Although the buffer is empty, the act of it being shown should be made visible. Solution: Make intro message persist if all is true: - Current buffer is the same as it was just after start, i.e. empty nameless with initial handle (i.e. 1). - Current window is the same as it was just after start, i.e. single non-floating with initial handle.
-rw-r--r--src/nvim/version.c8
-rw-r--r--test/functional/ui/messages_spec.lua30
2 files changed, 26 insertions, 12 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 14e2491d18..5443371ba7 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -2715,9 +2715,11 @@ void list_version(void)
/// Whether it still is not too late to show an intro message
bool may_show_intro(void)
{
- return (buf_is_empty(firstwin->w_buffer)
- && (firstwin->w_buffer->b_fname == NULL)
- && one_window(firstwin)
+ return (buf_is_empty(curbuf)
+ && (curbuf->b_fname == NULL)
+ && (curbuf->handle == 1)
+ && (curwin->handle == LOWEST_WIN_ID)
+ && one_window(curwin)
&& (vim_strchr(p_shm, SHM_INTRO) == NULL));
}
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index fb02af46b5..8a8808c3a7 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -1630,25 +1630,25 @@ describe('ui/ext_messages', function()
{1:~ }type :help iccf{5:<Enter>} for information {1: }|
{1:~ }|*5
]]
+ local showmode = { { '-- INSERT --', 3 } }
screen:expect(introscreen)
-- <c-l> (same as :mode) does _not_ clear intro message
feed('<c-l>i')
- screen:expect { grid = introscreen, showmode = { { '-- INSERT --', 3 } } }
+ screen:expect { grid = introscreen, showmode = showmode }
- -- opening a float also does not
- local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, {
+ -- opening a float without focus also does not
+ local win = api.nvim_open_win(api.nvim_create_buf(false, false), false, {
relative = 'editor',
height = 1,
width = 5,
row = 1,
col = 5,
})
- feed('float<esc><c-l>')
screen:expect {
grid = [[
- |
- {1:~ }{8:floa^t}{1: }|
+ ^ |
+ {1:~ }{8: }{1: }|
{1:~ }|*3
{MATCH:.*}|
{1:~ }|
@@ -1666,18 +1666,20 @@ describe('ui/ext_messages', function()
{1:~ }type :help iccf{5:<Enter>} for information {1: }|
{1:~ }|*5
]],
+ showmode = showmode,
}
+
api.nvim_win_close(win, true)
- screen:expect { grid = introscreen }
+ screen:expect { grid = introscreen, showmode = showmode }
-- but editing text does..
- feed('ix')
+ feed('x')
screen:expect {
grid = [[
x^ |
{1:~ }|*23
]],
- showmode = { { '-- INSERT --', 3 } },
+ showmode = showmode,
}
feed('<esc>:intro<cr>')
@@ -1715,6 +1717,16 @@ describe('ui/ext_messages', function()
}
end)
+ it('clears intro screen when new buffer is active', function()
+ api.nvim_set_current_buf(api.nvim_create_buf(true, false))
+ screen:expect {
+ grid = [[
+ ^ |
+ {1:~ }|*23
+ ]],
+ }
+ end)
+
it('supports global statusline', function()
feed(':set laststatus=3<cr>')
feed(':sp<cr>')