aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.builds/freebsd.yml5
-rw-r--r--.builds/openbsd.yml5
-rw-r--r--runtime/doc/api.txt15
-rw-r--r--src/nvim/api/vimscript.c30
-rw-r--r--src/nvim/window.c7
-rw-r--r--test/functional/api/vim_spec.lua76
-rw-r--r--test/functional/ui/messages_spec.lua106
7 files changed, 154 insertions, 90 deletions
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index 2d06b1e685..9347966a08 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -23,6 +23,11 @@ environment:
CMAKE_EXTRA_FLAGS: -DCI_BUILD=ON -DMIN_LOG_LEVEL=3
tasks:
+- should-run: |
+ # exclude runs when the only changes are made to these patterns
+ if ! git diff --quiet -- '!:.github'; then
+ complete-build;
+ fi
- build-deps: |
cd neovim
gmake deps
diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml
index 0aaa003820..7d2e489737 100644
--- a/.builds/openbsd.yml
+++ b/.builds/openbsd.yml
@@ -23,6 +23,11 @@ environment:
CMAKE_EXTRA_FLAGS: -DCI_BUILD=ON -DMIN_LOG_LEVEL=3
tasks:
+- should-run: |
+ # exclude runs when the only changes are made to these patterns
+ if ! git diff --quiet -- '!:.github'; then
+ complete-build;
+ fi
- build-deps: |
export AUTOCONF_VERSION=2.71
export AUTOMAKE_VERSION=1.16
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index d4477df803..bb7a238468 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1775,14 +1775,15 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
Dictionary containing command information, with these
keys:
• cmd: (string) Command name.
- • range: (number) Number of items in the command
- |<range>|. Can be 0, 1 or 2.
- • line1: (number) Starting line of command |<range>|. -1
- if command cannot take a range. |<line1>|
- • line2: (number) Final line of command |<range>|. -1 if
- command cannot take a range. |<line2>|
+ • range: (array) Command <range>. Can have 0-2 elements
+ depending on how many items the range contains. Has no
+ elements if command doesn't accept a range or if no
+ range was specified, one element if only a single range
+ item was specified and two elements if both range items
+ were specified.
• count: (number) Any |<count>| that was supplied to the
- command. -1 if command cannot take a count.
+ command. -1 if command cannot take a count. Mutually
+ exclusive with "range".
• reg: (number) The optional command |<register>|, if
specified. Empty string if not specified or if command
cannot take a register.
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index acd89119f9..698b2d06fb 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -747,13 +747,12 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, E
/// @param[out] err Error details, if any.
/// @return Dictionary containing command information, with these keys:
/// - cmd: (string) Command name.
-/// - range: (number) Number of items in the command |<range>|. Can be 0, 1 or 2.
-/// - line1: (number) Starting line of command |<range>|. -1 if command cannot take a range.
-/// |<line1>|
-/// - line2: (number) Final line of command |<range>|. -1 if command cannot take a range.
-/// |<line2>|
+/// - range: (array) Command <range>. Can have 0-2 elements depending on how many items the
+/// range contains. Has no elements if command doesn't accept a range or if
+/// no range was specified, one element if only a single range item was
+/// specified and two elements if both range items were specified.
/// - count: (number) Any |<count>| that was supplied to the command. -1 if command cannot
-/// take a count.
+/// take a count. Mutually exclusive with "range".
/// - reg: (number) The optional command |<register>|, if specified. Empty string if not
/// specified or if command cannot take a register.
/// - bang: (boolean) Whether command contains a |<bang>| (!) modifier.
@@ -849,15 +848,24 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx)));
}
- PUT(result, "range", INTEGER_OBJ(ea.addr_count));
- PUT(result, "line1", INTEGER_OBJ((ea.argt & EX_RANGE) ? ea.line1 : -1));
- PUT(result, "line2", INTEGER_OBJ((ea.argt & EX_RANGE) ? ea.line2 : -1));
+ if ((ea.argt & EX_RANGE) && !(ea.argt & EX_COUNT) && ea.addr_count > 0) {
+ Array range = ARRAY_DICT_INIT;
+ if (ea.addr_count > 1) {
+ ADD(range, INTEGER_OBJ(ea.line1));
+ }
+ ADD(range, INTEGER_OBJ(ea.line2));
+ PUT(result, "range", ARRAY_OBJ(range));;
+ } else {
+ PUT(result, "range", ARRAY_OBJ(ARRAY_DICT_INIT));
+ }
if (ea.argt & EX_COUNT) {
- if (ea.addr_count > 0 || cmd == NULL) {
+ if (ea.addr_count > 0) {
PUT(result, "count", INTEGER_OBJ(ea.line2));
- } else {
+ } else if (cmd != NULL) {
PUT(result, "count", INTEGER_OBJ(cmd->uc_def));
+ } else {
+ PUT(result, "count", INTEGER_OBJ(0));
}
} else {
PUT(result, "count", INTEGER_OBJ(-1));
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 6bae92c909..887df31650 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5490,7 +5490,7 @@ void win_setheight_win(int height, win_T *win)
}
}
cmdline_row = row;
- p_ch = MAX(Rows - cmdline_row, 1);
+ p_ch = MAX(Rows - cmdline_row, ui_has(kUIMessages) ? 0 : 1);
curtab->tp_ch_used = p_ch;
msg_row = row;
msg_col = 0;
@@ -5998,10 +5998,7 @@ void win_drag_status_line(win_T *dragwin, int offset)
clear_cmdline = true;
}
cmdline_row = row;
- p_ch = Rows - cmdline_row;
- if (p_ch < 1) {
- p_ch = 1;
- }
+ p_ch = MAX(Rows - cmdline_row, ui_has(kUIMessages) ? 0 : 1);
curtab->tp_ch_used = p_ch;
redraw_all_later(SOME_VALID);
showmode();
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 7e54ae0248..610036f484 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3104,9 +3104,7 @@ describe('API', function()
cmd = 'echo',
args = { 'foo' },
bang = false,
- line1 = -1,
- line2 = -1,
- range = 0,
+ range = {},
count = -1,
reg = '',
addr = 'none',
@@ -3142,9 +3140,7 @@ describe('API', function()
cmd = 'substitute',
args = { '/math.random/math.max/' },
bang = false,
- line1 = 4,
- line2 = 6,
- range = 2,
+ range = { 4, 6 },
count = -1,
reg = '',
addr = 'line',
@@ -3180,9 +3176,7 @@ describe('API', function()
cmd = 'buffer',
args = {},
bang = false,
- line1 = 1,
- line2 = 1,
- range = 1,
+ range = {},
count = 1,
reg = '',
addr = 'buf',
@@ -3218,9 +3212,7 @@ describe('API', function()
cmd = 'put',
args = {},
bang = false,
- line1 = 1,
- line2 = 1,
- range = 0,
+ range = {},
count = -1,
reg = '+',
addr = 'line',
@@ -3256,9 +3248,7 @@ describe('API', function()
cmd = 'write',
args = {},
bang = true,
- line1 = 1,
- line2 = 1,
- range = 0,
+ range = {},
count = -1,
reg = '',
addr = 'line',
@@ -3294,9 +3284,7 @@ describe('API', function()
cmd = 'split',
args = { 'foo.txt' },
bang = false,
- line1 = 1,
- line2 = 1,
- range = 0,
+ range = {},
count = -1,
reg = '',
addr = '?',
@@ -3333,9 +3321,7 @@ describe('API', function()
cmd = 'MyCommand',
args = { 'test', 'it' },
bang = true,
- line1 = 4,
- line2 = 6,
- range = 2,
+ range = { 4, 6 },
count = -1,
reg = '',
addr = 'line',
@@ -3371,9 +3357,7 @@ describe('API', function()
cmd = 'argadd',
args = { 'a.txt' },
bang = false,
- line1 = 0,
- line2 = 0,
- range = 0,
+ range = {},
count = -1,
reg = '',
addr = 'arg',
@@ -3410,9 +3394,7 @@ describe('API', function()
cmd = 'MyCommand',
args = { 'test it' },
bang = false,
- line1 = -1,
- line2 = -1,
- range = 0,
+ range = {},
count = -1,
reg = '',
addr = 'none',
@@ -3443,46 +3425,6 @@ describe('API', function()
}
}, meths.parse_cmd('MyCommand test it', {}))
end)
- it('sets correct default range', function()
- command('command -range=% -addr=buffers MyCommand echo foo')
- command('new')
- eq({
- cmd = 'MyCommand',
- args = {},
- bang = false,
- line1 = 1,
- line2 = 2,
- range = 0,
- count = -1,
- reg = '',
- addr = 'buf',
- magic = {
- file = false,
- bar = false
- },
- nargs = '0',
- nextcmd = '',
- mods = {
- browse = false,
- confirm = false,
- emsg_silent = false,
- hide = false,
- keepalt = false,
- keepjumps = false,
- keepmarks = false,
- keeppatterns = false,
- lockmarks = false,
- noautocmd = false,
- noswapfile = false,
- sandbox = false,
- silent = false,
- vertical = false,
- split = "",
- tab = 0,
- verbose = -1
- }
- }, meths.parse_cmd('MyCommand', {}))
- end)
it('errors for invalid command', function()
eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar', {}))
command('command! Fubar echo foo')
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index abb0948c60..3320f53d86 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -12,6 +12,7 @@ local nvim_prog = helpers.nvim_prog
local iswin = helpers.iswin
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
+local poke_eventloop = helpers.poke_eventloop
describe('ui/ext_messages', function()
local screen
@@ -1111,6 +1112,8 @@ describe('ui/ext_messages', function()
[3] = {bold = true},
[4] = {bold = true, foreground = Screen.colors.SeaGreen4},
[5] = {foreground = Screen.colors.Blue1},
+ [6] = {reverse = true},
+ [7] = {bold = true, reverse = true},
})
end)
@@ -1202,6 +1205,109 @@ describe('ui/ext_messages', function()
{content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" }
}}
end)
+
+ it('supports global statusline', function()
+ feed(":set laststatus=3<cr>")
+ feed(":sp<cr>")
+ feed("<c-l>")
+ feed(":set cmdheight<cr>")
+ screen:expect({grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {6:────────────────────────────────────────────────────────────────────────────────}|
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {7:[No Name] }|
+ ]], messages={
+ {content = { { " cmdheight=0" } }, kind = "" }
+ }})
+
+ feed("<c-w>+")
+ feed("<c-l>")
+ feed(":set cmdheight<cr>")
+ screen:expect({grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {6:────────────────────────────────────────────────────────────────────────────────}|
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {7:[No Name] }|
+ ]], messages={
+ {content = { { " cmdheight=0" } }, kind = "" }
+ }})
+
+ feed(":set mouse=a<cr>")
+ meths.input_mouse('left', 'press', '', 0, 12, 10)
+ poke_eventloop()
+ meths.input_mouse('left', 'drag', '', 0, 12, 10)
+ meths.input_mouse('left', 'drag', '', 0, 11, 10)
+ feed("<c-l>")
+ feed(":set cmdheight<cr>")
+ screen:expect({grid=[[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {6:────────────────────────────────────────────────────────────────────────────────}|
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {7:[No Name] }|
+ ]], messages={
+ {content = { { " cmdheight=0" } }, kind = "" }
+ }})
+ end)
end)
describe('ui/msg_puts_printf', function()