aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/lsp.txt4
-rw-r--r--runtime/doc/quickfix.txt17
-rw-r--r--runtime/lua/vim/lsp/rpc.lua28
-rw-r--r--src/nvim/ex_docmd.c9
-rw-r--r--src/nvim/option.c8
-rw-r--r--src/nvim/screen.c4
-rw-r--r--src/nvim/testdir/test_quickfix.vim27
-rw-r--r--test/functional/ui/fold_spec.lua38
8 files changed, 103 insertions, 32 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 5747ba6044..78829fbba1 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1062,9 +1062,9 @@ get_count({bufnr}, {severity}, {client_id})
let sl = ''
if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))')
let sl.='%#MyStatuslineLSP#E:'
- let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.diagnostic.get_count([[Error]])")}'
+ let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.diagnostic.get_count(vim.fn.bufnr('%'), [[Error]])")}'
let sl.='%#MyStatuslineLSP# W:'
- let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.diagnostic.get_count([[Warning]])")}'
+ let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.diagnostic.get_count(vim.fn.bufnr('%'), [[Warning]])")}'
else
let sl.='%#MyStatuslineLSPErrors#off'
endif
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 9da11a553d..d6ff3ea9ea 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -187,12 +187,17 @@ processing a quickfix or location list command, it will be aborted.
current window is used instead of the quickfix list.
*:cq* *:cquit*
-:[count]cq[uit] Quit Nvim with an error code, or the code specified in
- [count]. Useful when Nvim is called from another
- program: e.g. `git commit` will abort the comitting
- process, `fc` (built-in for shells like bash and zsh)
- will not execute the command.
-
+:cq[uit][!]
+:{N}cq[uit][!]
+:cq[uit][!] {N} Quit Vim with error code {N}. {N} defaults to one.
+ Useful when Vim is called from another program:
+ e.g., a compiler will not compile the same file again,
+ `git commit` will abort the committing process, `fc`
+ (built-in for shells like bash and zsh) will not
+ execute the command, etc. will not compile the same
+ file again.
+ {N} can also be zero, in which case Vim exits
+ normally.
WARNING: All changes in files are lost. It works like
":qall!" |:qall|, except that Nvim exits non-zero or
[count].
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index bbcc8ea6f9..90f51dfc5a 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -139,7 +139,7 @@ local header_start_pattern = ("content"):gsub("%w", function(c) return "["..c..c
--@private
--- The actual workhorse.
local function request_parser_loop()
- local buffer = ''
+ local buffer = '' -- only for header part
while true do
-- A message can only be complete if it has a double CRLF and also the full
-- payload, so first let's check for the CRLFs
@@ -154,17 +154,29 @@ local function request_parser_loop()
-- TODO(ashkan) I'd like to remove this, but it seems permanent :(
local buffer_start = buffer:find(header_start_pattern)
local headers = parse_headers(buffer:sub(buffer_start, start-1))
- buffer = buffer:sub(finish+1)
local content_length = headers.content_length
+ -- Use table instead of just string to buffer the message. It prevents
+ -- a ton of strings allocating.
+ -- ref. http://www.lua.org/pil/11.6.html
+ local body_chunks = {buffer:sub(finish+1)}
+ local body_length = #body_chunks[1]
-- Keep waiting for data until we have enough.
- while #buffer < content_length do
- buffer = buffer..(coroutine.yield()
- or error("Expected more data for the body. The server may have died.")) -- TODO hmm.
+ while body_length < content_length do
+ local chunk = coroutine.yield()
+ or error("Expected more data for the body. The server may have died.") -- TODO hmm.
+ table.insert(body_chunks, chunk)
+ body_length = body_length + #chunk
end
- local body = buffer:sub(1, content_length)
- buffer = buffer:sub(content_length + 1)
+ local last_chunk = body_chunks[#body_chunks]
+
+ body_chunks[#body_chunks] = last_chunk:sub(1, content_length - body_length - 1)
+ local rest = ''
+ if body_length > content_length then
+ rest = last_chunk:sub(content_length - body_length)
+ end
+ local body = table.concat(body_chunks)
-- Yield our data.
- buffer = buffer..(coroutine.yield(headers, body)
+ buffer = rest..(coroutine.yield(headers, body)
or error("Expected more data for the body. The server may have died.")) -- TODO hmm.
else
-- Get more data since we don't have enough.
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d65387f83b..0ffe67a4db 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6317,17 +6317,14 @@ static void ex_quit(exarg_T *eap)
}
}
-/*
- * ":cquit".
- */
+/// ":cquit".
static void ex_cquit(exarg_T *eap)
{
+ // this does not always pass on the exit code to the Manx compiler. why?
getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
}
-/*
- * ":qall": try to quit all windows
- */
+/// ":qall": try to quit all windows
static void ex_quit_all(exarg_T *eap)
{
if (cmdwin_type != 0) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 77a13b16b1..0034117ddc 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -342,6 +342,10 @@ static char_u SHM_ALL[] = {
///
/// Called only once from main(), just after creating the first buffer.
/// If "clean_arg" is true, Nvim was started with --clean.
+///
+/// NOTE: ELOG() etc calls are not allowed here, as log location depends on
+/// env var expansion which depends on expression evaluation and other
+/// editor state initialized here. Do logging in set_init_2 or later.
void set_init_1(bool clean_arg)
{
int opt_idx;
@@ -494,7 +498,6 @@ void set_init_1(bool clean_arg)
// this function.
char *rtp = runtimepath_default(clean_arg);
if (rtp) {
- ILOG("startup runtimepart/packpath value: %s", rtp);
set_string_default("runtimepath", rtp, true);
// Make a copy of 'rtp' for 'packpath'
set_string_default("packpath", rtp, false);
@@ -751,6 +754,9 @@ void free_all_options(void)
/// Initialize the options, part two: After getting Rows and Columns.
void set_init_2(bool headless)
{
+ // set in set_init_1 but logging is not allowed there
+ ILOG("startup runtimepath/packpath value: %s", p_rtp);
+
int idx;
// 'scroll' defaults to half the window height. The stored default is zero,
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 4373d6d5a8..2eeeebb88d 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2550,7 +2550,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
*/
cur = wp->w_match_head;
shl_flag = false;
- while ((cur != NULL || !shl_flag) && !number_only) {
+ while ((cur != NULL || !shl_flag) && !number_only
+ && foldinfo.fi_lines == 0
+ ) {
if (!shl_flag) {
shl = &search_hl;
shl_flag = true;
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 9c5f0777c6..5c84e45a79 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3,6 +3,8 @@
source check.vim
CheckFeature quickfix
+source screendump.vim
+
set encoding=utf-8
func s:setup_commands(cchar)
@@ -4410,6 +4412,31 @@ func Test_search_in_dirstack()
call delete('Xtestdir', 'rf')
endfunc
+" Test for :cquit
+func Test_cquit()
+ " Exit Vim with a non-zero value
+ if RunVim([], ["cquit 7"], '')
+ call assert_equal(7, v:shell_error)
+ endif
+
+ if RunVim([], ["50cquit"], '')
+ call assert_equal(50, v:shell_error)
+ endif
+
+ " Exit Vim with default value
+ if RunVim([], ["cquit"], '')
+ call assert_equal(1, v:shell_error)
+ endif
+
+ " Exit Vim with zero value
+ if RunVim([], ["cquit 0"], '')
+ call assert_equal(0, v:shell_error)
+ endif
+
+ " Exit Vim with negative value
+ call assert_fails('-3cquit', 'E16:')
+endfunc
+
" Test for adding an invalid entry with the quickfix window open and making
" sure that the window contents are not changed
func Test_add_invalid_entry_with_qf_window()
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 018049d2f4..7b05e90459 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -9,6 +9,15 @@ local meths = helpers.meths
local source = helpers.source
local assert_alive = helpers.assert_alive
+
+local content1 = [[
+ This is a
+ valid English
+ sentence composed by
+ an exhausted developer
+ in his cave.
+ ]]
+
describe("folded lines", function()
before_each(function()
clear()
@@ -119,18 +128,31 @@ describe("folded lines", function()
it("work with spell", function()
command("set spell")
- insert([[
- This is a
- valid English
- sentence composed by
- an exhausted developer
- in his cave.
- ]])
+ insert(content1)
+
+ feed("gg")
+ feed("zf3j")
+ if not multigrid then
+ screen:expect{grid=[[
+ {5:^+-- 4 lines: This is a······················}|
+ in his cave. |
+ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end
+ end)
+ it("work with matches", function()
+ insert(content1)
+ command("highlight MyWord gui=bold guibg=red guifg=white")
+ command("call matchadd('MyWord', '\\V' . 'test', -1)")
feed("gg")
feed("zf3j")
if not multigrid then
- -- screen:snapshot_util()
screen:expect{grid=[[
{5:^+-- 4 lines: This is a······················}|
in his cave. |