`find_command(s->ca.cmdchar) >= 0` was established near the start of
normal_execute(). And `unshift_special(&s->ca);` "should" not ever
result in s->ca.cmdchar containing a multibyte char.
So only an assert() is needed here.
Also give NVIM_TUI_ENABLE_CURSOR_SHAPE more granularity:
0 = do not change cursor shape
1 = non-blinking ("steady") cursor with mode-sensitive shape
2 = blinking cursor with mode-sensitive shape
Note: blink state is not changed for Konsole, instead user's terminal
preference makes the decision. (Can't do that for xterm-likes, DECSCUSR
forces us to choose blink-state.)
This is a temporary step until the TUI respects 'guicursor'
Ref: https://github.com/neovim/neovim/issues/2583#issuecomment-272988384
Test sometimes fails on AppVeyor (Windows). 300/50=6, but there could be
environment factors that miss the timer interval on the "edges".
timer_start() does not have such a hard requirement.
- Default to powershell.
- Avoid hardcoded "-c".
- Remove ^M character from received lines.
- pending_win32(): clear() is unnecessary and it pollutes the tests.
Closes#3973
Helped-by: Rui Abreu Ferreira <raf-ep@gmx.com>
When there is a difference in expected vs. actual row count, the user
gets a confusing message about being unable to string concat a nil value
from screen:expect.
This assert makes it clear what the problem is rather than requiring
people to dig through the code of screen:expect to determine what
happened.
Note some bugs were judged to have too ugly a fix to solve, tests to
demonstrate these problems, and the explanation behind not fixing them
are below.
describe('register . problems', function()
before_each(reset)
-- The difficulty here is: The basic requirement is that the text
-- inserted is treated as if it were typed in insert mode. This is why
-- the paste method is to enter insert mode and enter the ". register
-- into readbuf1.
-- We can't add a count into the readbuf here because the insert mode
-- count is implemented with readbuf2 which is checked for characters
-- after readbuf1.
-- Hence, the ".gp command (which adds extra characters into readbuf1
-- to emulate leaving the cursor after the text by moving the cursor
-- after inserting the text) would insert the motion characters into
-- the buffer instead of using them to move after the insert has been
-- done.
-- I could probably get this working properly with a special flag put
-- into start_redo_ins() and set in do_put(), but I think this adds
-- much more complexity than fixing this bug justifies.
pending('should not change the ". register with ".2p', function()
local orig_register = funcs.getreg('.')
feed('2".p')
eq(orig_register, funcs.getreg('.'))
end)
describe("cursor positioning after undo and redo with '.'", function()
before_each(reset)
local function make_cursor_test(macro_string)
return function()
feed(macro_string)
local afterpos = funcs.getcurpos()
local orig_string = curbuf_contents()
feed('u.')
eq(afterpos, funcs.getcurpos())
expect(orig_string)
end
end
-- The difficulty here is: setting the cursor after the end of the
-- pasted text is done by adding a motion command to the
-- stuffbuffer after the insert.
-- Modifying 'redobuff' is done in the code that handles inserting
-- text and moving around.
-- I could add a special case in ins_esc() that checks for a flag
-- set in do_put() to add the motion character to the redo buffer,
-- but I think that is starting to get way too convoluted for the
-- benefit.
pending('should be the same after ".gp and ".gpu.',
make_cursor_test('".gp'))
-- The difficulty here is: putting forwards is implemented by using
-- 'a' instead of 'i' to start insert.
-- Undoing with 'u' an insert that began with 'a' leaves the cursor
-- where the first character was inserted, not where the cursor was
-- when the 'a' was pressed.
-- We account for this the first time by saving the cursor position
-- in do_put(), but this isn't stored in redobuff for a second time
-- around.
-- We can't change how such a fundamental action as undo after
-- inserting with 'a' behaves, we could add in a special case
-- whereby we set a flag in do_put() and read it when entering
-- insert mode but this seems like way too much to fix such a minor
-- bug.
pending('should be the same after ".pu. and ".pu.u.',
make_cursor_test('".pu.'))
end)
end)
Also make setpos("'A", [999, 1, 1, 0]) fail, i.e. return -1 (assuming there is no buffer 999).
Fixes#5713
Background:
`:help setpos()` mentions an argument `"bufnum"` that determines the buffer a mark should be put in.
This argument is respected for uppercase marks, but not for lowercase marks.
This is reasonable (though I personally would like `setpos()` to be able to set marks in other buffers), but the help doesn't mention this anywhere.
It's also strange that attempting to change buffers with `setpos('.', [bufnr('#'), 1, 1, 0])` alerts the user that having a different buffer is an error, while attempting to set a mark with `setpos("'d", [bufnr('#'), 1, 1, 0])` doesn't tell the user that the `"bufnum"` argument is an error.
While a job callback is active, it may be invoked again. Since the
data handled by the first invocation of the callback hasn't been marked
as consumed, the subsequent invocation will see the same data.
Reported-by: Daniel Hahler
Patch-by: oni-link
Closes#5889
This fixes a use-after-free noticed by ASAN which would occur when a
dictwatcher was still active on a dictionary when the dictionary was
freed.
fun! MakeWatch()
let d = {'foo': 'bar'}
call dictwatcheradd(d, 'foo', function('...'))
endfun
Patch-by: oni-link
Closes#5930
Do _not_ set v:shell_error on parameter validation error.
system([...]) does not invoke a shell, so this change is somewhat
questionable. But `:help v:shell_error` is sufficiently vague to allow
-1 in this case.
After #4964 environment variables in the XDG "fallback" table are no
longer expanded.
Fallback to correctly expanded $LOCALAPPDATA, $TEMP. If that fails
(unlikely), fallback to hard-coded paths (e.g. ~/AppData/Local).
Closes#5255
On Windows, if the nvim process has a directory open the lua process
cannot remove it. After failing once, it's safe to force `nvim` to the
top-level directory. Then try again.
- Eliminate global test_autochdir.
- Eliminate VimL function test_autochdir()
- Use a lua test instead. Fails correctly after reverting
0c43479979 / vim-patch:7.4.2015.
- Improve test reliability by only checking for a line with the string
we are interested in ("Interrupt").
- Try to avoid OOM by loading an existing big file instead of looping to
create one.
Keeps arguments separated and not joined as a single string as long as possible.
Abstracts away additional arguments so that Gcc:preprocess should work for
compilers with different conventions should they be supported.
Works by saving all preprocessor defines and reusing them on each run. This also
saves NVIM_HEADER_H defines. Saving other defines is needed for defines like
`Map(foo, bar)` which are sometimes used to declare types or functions. Saving
types or function declarations is not needed because they are recorded as luajit
state.
Fixes#5857
Also fixed dumping of partials by encode_vim_to_object and added code which is
able to work with partials and dictionaries to test/unit/eval/helpers.lua
(mostly copied from #5119, except for partials handling).
Occurs when trying to dump a partial with attached self dictionary which
references that partial. “Infinite” loop should normally result in Neovim killed
by OOM killer.
Also moved the place when partials are unreferenced by clear_tv: from
…FUNC_START to …FUNC_END.
This ameliorates use-cases like:
:!cat foo.txt
:make
where the user is interested in the last few lines of output.
Try these shell-based ex-commands before/after this commit:
:grep -r '' *
:make
:!yes
:!grep -r '' *
:!git grep ''
:!cat foo
:!echo foo
:!while true; do date; done
:!for i in `seq 1 20000`; do echo XXXXXXXXXX $i; done
In all cases the last few lines of the command should always be shown,
regardless of where throttling was triggered.
Periodically skip :! spam. This is a "cheat" that works for all UIs and greatly
improves responsiveness when :! spams MB or GB of output:
:!yes
:!while true; do date; done
:!git grep ''
:grep -r '' *
After ~10KB of data is seen from a single :! invocation, output will be skipped
for ~1s and three dots "..." will pulse in the bottom-left. Thereafter the
behavior alternates at every:
* 10KB received
* ~1s throttled
This also avoids out-of-memory which could happen with large :! outputs.
Note: This commit does not change the behavior of execute(':!foo').
execute(':!foo') returns the string ':!foo^M', it captures *only* Vim
messages, *not* shell command output. Vim behaves the same way.
Use system('foo') for capturing shell command output.
Closes#1234
Helped-by: oni-link <knil.ino@gmail.com>
Closes#1234
multiqueue:
- Implement multiqueue_size()
- Rename MultiQueueItem.parent to MultiQueueItem.parent_item, to avoid confusion
with MultiQueue.parent.
https://github.com/mpeterv/luacheck/pull/81#issuecomment-261099606
> If you really want to use bleeding-edge version you should get the
> rockspec from master branch, not a fixed commit ...
> The correct way to install from a specific commit is cloning that
> commit and running "luarocks make" from project directory. The reason
> is that running "install" or "build" on an scm rockspec fetches
> sources from master but uses build description from the rockspec
> itself, which may be outdated.
Problem: Using freed memory after setqflist() and ":caddbuffer". (Dominique)
Solution: Set qf_ptr when adding the first item to the quickfix list.
8b20179c65
In order to not conflict with new error codes that Vim adds, all Neovim
error codes should be above 5000. The three existing sub-5000 error
codes (E926, E951, and E952) are now E50003, E5004, and E5005
respectively.
E953 was removed in 6167ce6df2, so just
remove it from the help.
Problem: Crash when an autocommand changes a quickfix list. (Dominique)
Solution: Check wether an entry is still valid. (Yegappan Lakshmanan,
Hirohito Higashi)
ffec3c5349
Problem: Order of matches for 'omnifunc' is messed up. (Danny Su)
Solution: Do not set compl_curr_match when called from complete_check().
(closesvim/vim#1168)
472e85970e
* health.vim: Include v:throwpoint in error message
* health/provider.vim: Check for ruby executable
* health/provider.vim: Combine subprocess stdout and stderr
* test: Updated CheckHealth test
Problem: Vertical movement after CTRL-A ends up in the wrong column.
(Urtica Dioica)
Solution: Set curswant when appropriate. (Hirohito Higashi)
8e08125d3a
- Use a standard scratch buffer instead of a new 'buftype', functions
like curbufIsChanged() already have special handling for scratch bufs.
- Cleanup some stuff from the previous merge.
- Add support for :smagic, :snomagic. Closes#5578
Add tests for undotree().
Helped-by: Björn Linse <bjorn.linse@gmail.com>
When "curhead" points to a valid head, the value of "newhead" is
meaningless (and really should be set to null). The undo state for
a buffer is _logically_ the enum:
enum UndoState {
CurrentHead(head),
NewHead(head),
EmptyTree
}
nvim _represents_ this as: whenever `curbuf->b_u_curhead` is nonnull it
should be used as the current head, and `curbuf->b_u_newhead` is
ignored. If the there is a current head, then this will be redoed on the
next redo, and its parent will be undone on next undo. Only if
`b_u_curhead` is NULL, `b_u_newhead` will be used as the head to undo
(and it is not possible to redo). Also both can be NULL, to indicate an
empty undotree. (To be fair, this only strictly true when calling undo.c
from the outside, in some places _within_ a function in undo.c both
values might be meaningful)
Apparently `undotree()` breaks this non-abstraction, this _cosmetic_
issue can easily be fixed by `ex_substitute` also saving and restoring
`b_u_newhead`, but is doesn't reflect any error really how
`u_undo_and_forget` manipulates the _actual_ state of the undo tree.
'inccommand' allows us to expand the feature to other commands, such as:
:cdo
:cfdo
:global
Also rename "IncSubstitute" highlight group to "Substitute".
[inc_sub] is less obvious for users. Also, in the future we may want to
generalize the idea of a "preview buffer", or "incremental commands"
besides :substitute.
- Eliminate/isolate static/global variables
- Remove special-case parameter from buflist_new()
- Remove special-case ECMD_RESERVED_BUFNR
- To determine when u_undo_and_forget() should be done, check
b_changedtick instead of a heuristic.
- use mb_string2cells() instead of strlen() to measure the :sub patterns
- call ml_close() before buf_clear_file(). Avoids leaks caught by ASan.
Original patch by:
Robin Elrharbi-Fleury (Robinhola)
Audrey Rayé (Adrey06)
Philémon Hullot (DesbyP)
Aymeric Collange (aym7)
Clément Guyomard (Clement0)
The 'dump and read back mark " from a closed tab' test needs to actually
create a second tab. Since it wasn't doing so, the 'q!' command caused
nvim to exit and the subsequent 'qall' command fails.
API level is disconnected from NVIM version. The API metadata holds the
current API level, and the lowest backwards-compatible level supported
by this instance.
Release 0.1.6 is the first release that reports the Nvim version and API
level.
metadata['version'] = {
major: 0,
minor: 1,
patch: 6,
api_level: 1,
api_compatible: 0,
api_prerelease: false,
}
The API level may remain unchanged across Nvim releases if the API has
not changed.
When changing the API,
- set NVIM_API_PRERELEASE to true
- increment NVIM_API_LEVEL (at most once per Nvim version)
- adjust NVIM_API_LEVEL_COMPAT if backwards-compatibility was broken
api_level_0.mpack was generated from Nvim 0.1.5 with:
nvim --api-info
The API level is disconnected from the NVIM version. The API metadata
holds the current API level, and the lowest backwards-compatible level
supported by this instance.
Release 0.1.6 will be the first release reporting the Nvim version and
API level.
metadata['version'] = {
major: 0,
minor: 1,
patch: 6,
prerelease: true,
api_level: 1,
api_compatible: 0,
}
The API level may remain unchanged across Neovim releases if the API has
not changed.
When changing the API the CMake variable NVIM_API_PRERELEASE is set to
true, and NVIM_API_CURRENT/NVIM_API_COMPATIBILITY are incremented
accordingly.
The functional tests check the API table against fixtures of past
versions of Neovim. It compares all the functions in the old table with
the new one, it does ignore some metadata attributes that do not alter
the function signature or were removed since 0.1.5. Currently the only
fixture is 0.mpack, generated from Neovim 0.1.5 with nvim --api-info.
Closes#5449
A file containing the string "vim" followed by a very large number in a modeline
location will trigger an overflow in getdigits() which is called by
chk_modeline() when trying to parse the version number.
Add getdigits_safe(), which does not assert overflows, but reports them to the
caller.
Problem: Mark " is not set when closing a window in another tab. (Guraga)
Solution: Check all tabs for the window to be valid. (based on patch by
Hirohito Higashi, closesvim/vim#974)
e59215c7dc
Problem: When using Insert mode completion but not actually inserting
anything an undo item is still created. (Tommy Allen)
Solution: Do not call stop_arrow() when not inserting anything.
Closes#3529Closes#5241
In Vim,
:echo system('cat - &', 'foo')
works because for both system() and :! Vim writes input to a temp file and uses
shell syntax to redirect the file to the backgrounded `cat` (get_cmd_output()
.. make_filter_cmd()).
In Nvim,
:echo system('cat - &', 'foo')
fails because we write the input directly via pipes (shell.c:do_os_system()),
but (per POSIX[1]) backgrounded process input stream is redirected from
/dev/null (unless overridden by shell redirection; supported only by some shells
[2]), so our writes are ignored, the process exits quickly, and if we are
writing data larger than the buffer size we'll see EPIPE.
This still works:
:%w !tee > foo1358.txt &
but this does not:
:%w !tee foo1358.txt &
though it *should* (why doesn't it?) because we still do the temp file dance
in do_bang() .. do_filter().
[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_03_02
[2] http://unix.stackexchange.com/a/71218