fix(messages): allow more prompt in headless mode with UI (#27905)

Problem:  More prompt is not shown in headless mode even if there is a
          UI attached.
Solution: Don't skip more prompt when there is a UI active.
This commit is contained in:
zeertzjq 2024-03-18 10:34:27 +08:00 committed by GitHub
parent 3b29b39e6d
commit eabf9de1dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 56 additions and 5 deletions

View File

@ -2713,7 +2713,7 @@ static bool do_more_prompt(int typed_char)
// If headless mode is enabled and no input is required, this variable
// will be true. However If server mode is enabled, the message "--more--"
// should be displayed.
bool no_need_more = headless_mode && !embedded_mode;
bool no_need_more = headless_mode && !embedded_mode && !ui_active();
// We get called recursively when a timer callback outputs a message. In
// that case don't show another prompt. Also when at the hit-Enter prompt

View File

@ -775,18 +775,23 @@ describe('treesitter highlighting (C)', function()
declarator: (pointer_declarator) @variable.parameter)
]]
exec_lua([[
exec_lua(
[[
local query = ...
vim.treesitter.query.set('c', 'highlights', query)
vim.treesitter.highlighter.new(vim.treesitter.get_parser(0, 'c'))
]], query)
]],
query
)
screen:expect{grid=[[
screen:expect {
grid = [[
void foo(int {4:*}{11:bar}); |
^ |
{1:~ }|*15
|
]]}
]],
}
end)
end)

View File

@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed
local eval = helpers.eval
local eq = helpers.eq
local neq = helpers.neq
local command = helpers.command
local set_method_error = helpers.set_method_error
local api = helpers.api
@ -15,6 +16,7 @@ local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
local poke_eventloop = helpers.poke_eventloop
local assert_alive = helpers.assert_alive
local retry = helpers.retry
local is_os = helpers.is_os
local is_ci = helpers.is_ci
local fn = helpers.fn
@ -2497,3 +2499,47 @@ aliquip ex ea commodo consequat.]]
}
end)
end)
it('pager works in headless mode with UI attached', function()
skip(is_os('win'))
clear()
local child_server = assert(helpers.new_pipename())
fn.jobstart({ nvim_prog, '--clean', '--headless', '--listen', child_server })
retry(nil, nil, function()
neq(nil, vim.uv.fs_stat(child_server))
end)
local child_session = helpers.connect(child_server)
local child_screen = Screen.new(40, 6)
child_screen:attach(nil, child_session)
child_session:notify('nvim_command', [[echo range(100)->join("\n")]])
child_screen:expect([[
0 |
1 |
2 |
3 |
4 |
-- More --^ |
]])
child_session:request('nvim_input', 'G')
child_screen:expect([[
95 |
96 |
97 |
98 |
99 |
Press ENTER or type command to continue^ |
]])
child_session:request('nvim_input', 'g')
child_screen:expect([[
0 |
1 |
2 |
3 |
4 |
-- More --^ |
]])
end)