aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-06-21 10:00:35 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-07-05 15:52:59 +0200
commit399eb49bafcbd4bf60ff32e339a1f673e75acf2b (patch)
treeb5712993e7e68ffce7b9a1193b01a5f6f6784fa8
parent0d82aaf5866b954ab0fe4831df499a4713eeae35 (diff)
downloadrneovim-399eb49bafcbd4bf60ff32e339a1f673e75acf2b.tar.gz
rneovim-399eb49bafcbd4bf60ff32e339a1f673e75acf2b.tar.bz2
rneovim-399eb49bafcbd4bf60ff32e339a1f673e75acf2b.zip
highlight: show "hi Group" message correctly when not using the screen
ext_message doesn't set msg_col. Add a space and let client deal with wrapping. When using silent redirect show the unwrapped message form. Removed check is already part of msg_advance()
-rw-r--r--src/nvim/syntax.c16
-rw-r--r--test/functional/ui/messages_spec.lua50
-rw-r--r--test/functional/ui/screen.lua8
3 files changed, 67 insertions, 7 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 8d846df8b6..354590b9ec 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -7211,6 +7211,7 @@ static bool syn_list_header(const bool did_header, const int outlen,
{
int endcol = 19;
bool newline = true;
+ bool adjust = true;
if (!did_header) {
msg_putchar('\n');
@@ -7219,6 +7220,9 @@ static bool syn_list_header(const bool did_header, const int outlen,
}
msg_outtrans(HL_TABLE()[id - 1].sg_name);
endcol = 15;
+ } else if (ui_has(kUIMessages) || msg_silent) {
+ msg_putchar(' ');
+ adjust = false;
} else if (msg_col + outlen + 1 >= Columns) {
msg_putchar('\n');
if (got_int) {
@@ -7230,12 +7234,14 @@ static bool syn_list_header(const bool did_header, const int outlen,
}
}
- if (msg_col >= endcol) /* output at least one space */
- endcol = msg_col + 1;
- if (Columns <= endcol) /* avoid hang for tiny window */
- endcol = Columns - 1;
+ if (adjust) {
+ if (msg_col >= endcol) {
+ // output at least one space
+ endcol = msg_col + 1;
+ }
- msg_advance(endcol);
+ msg_advance(endcol);
+ }
/* Show "xxx" with the attributes. */
if (!did_header) {
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index e6df9885ef..09e13b1464 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -5,6 +5,7 @@ local eval = helpers.eval
local eq = helpers.eq
local command = helpers.command
local set_method_error = helpers.set_method_error
+local meths = helpers.meths
describe('ui/ext_messages', function()
@@ -332,6 +333,22 @@ describe('ui/ext_messages', function()
}}
end)
+ it(':hi Group output', function()
+ feed(':hi ErrorMsg<cr>')
+ screen:expect{grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]], messages={
+ {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "},
+ {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " },
+ {"guifg=", 5 }, { "White " }, { "guibg=", 5 }, { "Red" }},
+ kind = ""}
+ }}
+ end)
+
it("doesn't crash with column adjustment #10069", function()
feed(':let [x,y] = [1,2]<cr>')
feed(':let x y<cr>')
@@ -786,6 +803,7 @@ describe('ui/builtin messages', function()
[2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[3] = {bold = true, reverse = true},
[4] = {bold = true, foreground = Screen.colors.SeaGreen4},
+ [5] = {foreground = Screen.colors.Blue1},
})
end)
@@ -806,6 +824,38 @@ describe('ui/builtin messages', function()
end
end}
end)
+
+ it(':hi Group output', function()
+ screen:try_resize(70,7)
+ feed(':hi ErrorMsg<cr>')
+ screen:expect([[
+ |
+ {1:~ }|
+ {1:~ }|
+ {3: }|
+ :hi ErrorMsg |
+ ErrorMsg {2:xxx} {5:ctermfg=}15 {5:ctermbg=}1 {5:guifg=}White {5:guibg=}Red |
+ {4:Press ENTER or type command to continue}^ |
+ ]])
+
+ feed('<cr>')
+ screen:try_resize(30,7)
+ feed(':hi ErrorMsg<cr>')
+ screen:expect([[
+ :hi ErrorMsg |
+ ErrorMsg {2:xxx} {5:ctermfg=}15 |
+ {5:ctermbg=}1 |
+ {5:guifg=}White|
+ {5:guibg=}Red |
+ {4:Press ENTER or type command to}|
+ {4: continue}^ |
+ ]])
+ feed('<cr>')
+
+ -- screen size doesn't affect internal output #10285
+ eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
+ meths.command_output("hi ErrorMsg"))
+ end)
end)
describe('ui/ext_messages', function()
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 0367e85028..f1254b68f6 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -1194,6 +1194,10 @@ function Screen:render(headers, attr_state, preview)
return rv
end
+local remove_all_metatables = function(item, path)
+ if path[#path] ~= inspect.METATABLE then return item end
+end
+
function Screen:print_snapshot(attrs, ignore)
attrs = attrs or self._default_attr_ids
if ignore == nil then
@@ -1247,8 +1251,8 @@ function Screen:print_snapshot(attrs, ignore)
io.stdout:write( "]]"..attrstr)
for _, k in ipairs(ext_keys) do
if ext_state[k] ~= nil then
- -- TODO(bfredl): improve formating, remove ext metatables
- io.stdout:write(", "..k.."="..inspect(ext_state[k]))
+ -- TODO(bfredl): improve formatting
+ io.stdout:write(", "..k.."="..inspect(ext_state[k],{process=remove_all_metatables}))
end
end
print((keys and "}" or ")").."\n")