aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
Commit message (Collapse)AuthorAge
...
* normal: Add figure braces so that code is clearerZyX2017-04-16
|
* normal: Clarify the codeZyX2017-04-16
| | | | Current variant works only because of PUT_FIXINDENT being equal to true.
* normal: Remove unneeded assignmentZyX2017-04-16
|
* coverity/161194: Restore check for 'keywordprg' being ":help"James McCoy2017-03-29
| | | | | | | | | | | 998d0ffc09d5c7358db62dc88c2e2b87622f60b5 removed the explicit check for ":help", relying instead on whether the user was in a help buffer. However, this breaks escaping the identifier for use in the lookup command. 2f54d6927cc02484b528a5e8b25b64c8d6580ddd tried to fix this by removing "!kp_ex" in "if (cmdchar == 'K' && !kp_ex)", but that causes shell escaping to be used instead of escaping for tag lookup.
* eval: Move remaining get_tv_string* functions to eval/typval.cZyX2017-03-29
|
* eval,*: Move get_tv_string to typval.cZyX2017-03-29
| | | | Function was renamed and changed to return `const char *`.
* eval: Split eval.c into smaller filesZyX2017-03-29
|
* refactor: Remove allow_keys global (#6346)Matthew Malcomson2017-03-25
| | | | | | * The allow_keys global is unused in nvim, remove it * clint
* terminal: Avoid invalid cursor col (#6265)Justin M. Keyes2017-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch-by: oni-link <knil.ino@gmail.com> Closes #6203 https://s3.amazonaws.com/archive.travis-ci.org/jobs/206794197/log.txt References #3161 [ RUN ] ...d/neovim/neovim/test/functional/terminal/buffer_spec.lua @ 199: terminal buffer term_close() use-after-free #4393 ./test/functional/helpers.lua:187: attempt to perform arithmetic on local 'written' (a nil value) stack traceback: ./test/functional/helpers.lua:187: in function 'nvim_feed' ./test/functional/helpers.lua:329: in function 'execute' ...d/neovim/neovim/test/functional/terminal/buffer_spec.lua:206: in function <...d/neovim/neovim/test/functional/terminal/buffer_spec.lua:199> [ ERROR ] ...d/neovim/neovim/test/functional/terminal/buffer_spec.lua @ 199: terminal buffer term_close() use-after-free #4393 (199.47 ms) ==================== File /home/travis/build/neovim/neovim/build/log/ubsan.15466 ==================== = ================================================================= = ==15466==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000029101 at pc 0x000000ea7ba0 bp 0x7ffd5bb628c0 sp 0x7ffd5bb628b8 = READ of size 1 at 0x621000029101 thread T0 = #0 0xea7b9f in utf_head_off /home/travis/build/neovim/neovim/src/nvim/mbyte.c:1637:7 = #1 0xeaaf53 in mb_adjustpos /home/travis/build/neovim/neovim/src/nvim/mbyte.c:1840:16 = #2 0xeaab48 in mb_adjust_cursor /home/travis/build/neovim/neovim/src/nvim/mbyte.c:1825:3 = #3 0x11000d0 in normal_finish_command /home/travis/build/neovim/neovim/src/nvim/normal.c:928:5 = #4 0x1077df1 in normal_execute /home/travis/build/neovim/neovim/src/nvim/normal.c:1147:3 = #5 0x16ff943 in state_enter /home/travis/build/neovim/neovim/src/nvim/state.c:58:26 = #6 0x102d8db in normal_enter /home/travis/build/neovim/neovim/src/nvim/normal.c:463:3 = #7 0xdf3398 in main /home/travis/build/neovim/neovim/src/nvim/main.c:540:3 = #8 0x2b973e8b4f44 in __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287 = #9 0x447445 in _start (/home/travis/build/neovim/neovim/build/bin/nvim+0x447445) = = 0x621000029101 is located 1 bytes to the right of 4096-byte region [0x621000028100,0x621000029100) = allocated by thread T0 here: = #0 0x4f17b8 in malloc (/home/travis/build/neovim/neovim/build/bin/nvim+0x4f17b8) = #1 0xf1f374 in try_malloc /home/travis/build/neovim/neovim/src/nvim/memory.c:84:15 = #2 0xf1f534 in xmalloc /home/travis/build/neovim/neovim/src/nvim/memory.c:118:15 = #3 0xebe6a8 in mf_alloc_bhdr /home/travis/build/neovim/neovim/src/nvim/memfile.c:646:17 = #4 0xebc394 in mf_new /home/travis/build/neovim/neovim/src/nvim/memfile.c:297:12 = #5 0xed1368 in ml_new_data /home/travis/build/neovim/neovim/src/nvim/memline.c:2704:16 = #6 0xece6ab in ml_open /home/travis/build/neovim/neovim/src/nvim/memline.c:349:8 = #7 0x6438ad in open_buffer /home/travis/build/neovim/neovim/src/nvim/buffer.c:109:7 = #8 0xa6ec8d in do_ecmd /home/travis/build/neovim/neovim/src/nvim/ex_cmds.c:2489:24 = #9 0xb5a0f9 in do_exedit /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:6723:9 = #10 0xb791f8 in ex_edit /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:6651:3 = #11 0xb28b43 in do_one_cmd /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:2198:5 = #12 0xb077a7 in do_cmdline /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:601:20 = #13 0x10905db in nv_colon /home/travis/build/neovim/neovim/src/nvim/normal.c:4495:18 = #14 0x1077de8 in normal_execute /home/travis/build/neovim/neovim/src/nvim/normal.c:1144:3 = #15 0x16ff943 in state_enter /home/travis/build/neovim/neovim/src/nvim/state.c:58:26 = #16 0x102d8db in normal_enter /home/travis/build/neovim/neovim/src/nvim/normal.c:463:3 = #17 0xdf3398 in main /home/travis/build/neovim/neovim/src/nvim/main.c:540:3 = #18 0x2b973e8b4f44 in __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287 = = SUMMARY: AddressSanitizer: heap-buffer-overflow /home/travis/build/neovim/neovim/src/nvim/mbyte.c:1637:7 in utf_head_off stack traceback: ./test/helpers.lua:80: in function 'check_logs' ./test/functional/helpers.lua:639: in function <./test/functional/helpers.lua:638> [----------] 9 tests from /home/travis/build/neovim/neovim/test/functional/terminal/buffer_spec.lua (2263.12 ms total)
* test/legacy: fix test_normal.vimJustin M. Keyes2017-03-19
|
* vim-patch:8.0.0179raichoo2017-03-19
| | | | | | | | Problem: 'formatprg' is a global option but the value may depend on the type of buffer. (Sung Pae) Solution: Make 'formatprg' global-local. (closes vim/vim#1380) https://github.com/vim/vim/commit/9be7c04e6cd5b0facedcb56b09a5bcfc339efe03
* linter: make changes pass the linterraichoo2017-03-19
|
* vim-patch:8.0.0066raichoo2017-03-19
| | | | | | | | | Problem: when calling an operator function when 'linebreak' is set, it is internally reset before calling the operator function. Solution: Restore 'linebreak' before calling op_function(). (Christian Brabandt) https://github.com/vim/vim/commit/4a08b0dc4dd70334056fc1bf069b5e938f2ed7d5
* vim-patch:8.0.0060raichoo2017-03-19
| | | | | | | | Problem: When using an Ex command for 'keywordprg' it is escaped as with a shell command. (Romain Lafourcade) Solution: Escape for an Ex command. (closes vim/vim#1175) https://github.com/vim/vim/commit/426f3754223c8ff8a1bc51d6ba1eba11e8982ebc
* vim-patch:7.4.2347raichoo2017-03-19
| | | | | | | | | Problem: Crash when closing a buffer while Visual mode is active. (Dominique Pelle) Solution: Adjust the position before computing the number of lines. When closing the current buffer stop Visual mode. https://github.com/vim/vim/commit/c4a908e83690844b0d3a46124ba6af7d23485d69
* vim-patch:7.4.2326raichoo2017-03-19
| | | | | | | | Problem: Illegal memory access when Visual selection starts in invalid position. (Dominique Pelle) Solution: Correct position when needed. https://github.com/vim/vim/commit/d5824ce1b5491df7d2eb0b66189d366fa67b4585
* vim-patch:7.4.2101James McCoy2017-03-11
| | | | | | | Problem: Looping over windows, buffers and tab pages is inconsistant. Solution: Use FOR_ALL_ macros everywhere. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
* vim-patch:7.4.2069James McCoy2017-03-11
| | | | | | | Problem: spell.c is too big. Solution: Split it in spell file handling and spell checking. https://github.com/vim/vim/commit/9ccfebddc3ff2a3c2853cf706fd4c26f639bf381
* 'cpoptions': "_" flag to toggle `cw` behaviour #6235raichoo2017-03-10
| | | | | | | | | | | | | | | `cw` and `cW` behave like `ce` and `cE` respectively. This is inconsistent compared to `dw` and `dW`. Introduce a new cpoptions flag "_" to toggle the Vi behavior. Closes #6234 Patch-by: Christian Brabandt <cblists@256bit.org> References: https://github.com/chrisbra/vim-mq-patches/blob/master/cpo_changeword https://groups.google.com/d/msg/vim_use/aaBqT6ECkA4/ALf4odKzEDgJ https://groups.google.com/d/msg/vim_dev/Dpn3xtUF16I/T6JcOPKN6usJ http://www.reddit.com/r/vim/comments/26nut8/why_does_cw_work_like_ce/
* vim-patch:7.4.1981 (#6192)lonerover2017-03-02
| | | | | | Problem: No testing for Farsi code. Solution: Add a minimal test. Clean up Farsi code. https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
* Merge #6142 from justinmk/term-modifiableJustin M. Keyes2017-02-27
|\ | | | | terminal: 'modifiable'; 'scrollback'; follow output only if cursor is on last line
| * terminal: 'scrollback'Justin M. Keyes2017-02-26
| | | | | | | | Closes #2637
| * terminal: Allow undo and 'modifiable'.Justin M. Keyes2017-02-26
| | | | | | | | | | | | | | Partial step towards #2637. Will crash if *all* lines are deleted. Closes #2607 References #5431
* | vim-patch:8.0.0379James McCoy2017-02-26
|/ | | | | | | Problem: CTRL-Z and mouse click use CTRL-O unnecessary. Solution: Remove stuffing CTRL-O. (James McCoy, closes vim/vim#1453) https://github.com/vim/vim/commit/74a47162a07fddb532f4bead212f6c80ef474ae7
* Merge remote-tracking branch 'origin/master' into lambdaJames McCoy2017-02-22
|\
| * *: Partial string handling refactoringZyX2017-02-15
| | | | | | | | | | | | | | | | Main points: - Replace `char_u` with `char` in some cases. - Remove `str[len] = NUL` hack in some cases when `str` may be considered `const`.
* | vim-patch:7.4.2090Michael Ennen2017-02-14
|/ | | | | | | | Problem: Using submatch() in a lambda passed to substitute() is verbose. Solution: Use a static list and pass it as an optional argument to the function. Fix memory leak. https://github.com/vim/vim/commit/df48fb456fb6bf63d94cad9b302ff01d8ee8d311
* lintJames McCoy2017-02-06
|
* vim-patch:8.0.0208James McCoy2017-02-06
| | | | | | | | | | | | Problem: Internally used commands for CTRL-Z and mouse click end up in history. (Matthew Malcomson) Solution: Use do_cmdline_cmd() instead of stuffing them in the readahead buffer. (James McCoy, closes vim/vim#1395) https://github.com/vim/vim/commit/25b0e6b701a7a8dfcb4f60e217360a5c75053d8c Closes #5966 Closes #5967
* coverity/133845: Negative array index read. (FP)Justin M. Keyes2017-01-23
| | | | | | | | `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.
* put fixup, esp. ". register close #5709 #5781Matthew Malcomson2017-01-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* vim-patch:7.4.1940 (#5849)lonerover2016-12-31
| | | | | | Problem: "gd" hangs in some situations. (Eric Biggers) Solution: Remove the SEARCH_START flag when looping. Add a test. https://github.com/vim/vim/commit/23c60f21b07b04351d846e6fbf4f4abd9aa09345
* vim-patch:7.4.1559Michael Ennen2016-12-12
| | | | | | | Problem: Passing cookie to a callback is clumsy. Solution: Change function() to take arguments and return a partial. https://github.com/vim/vim/commit/1735bc988c546cc962c5f94792815b4d7cb79710
* lintJames McCoy2016-12-02
|
* vim-patch:7.4.1748James McCoy2016-12-02
| | | | | | | | Problem: "gD" does not find match in first column of first line. (Gary Johnson) Solution: Accept match at the cursor. https://github.com/vim/vim/commit/1538fc34fae3fae39773ca43f6ff52401fce61d8
* folds: Do not auto-update folds for some foldmethods. #5426Shougo Matsushita2016-10-19
|
* event/multiqueue.c: Rename "queue" to "multiqueue".Justin M. Keyes2016-10-02
| | | | | | | | | | | | | | `lib/queue.h` implements a basic queue. `event/queue.c` implements a specialized data structure on top of lib/queue.h; it is not a "normal" queue. Rename the specialized multi-level queue implemented in event/queue.c to "multiqueue", to avoid confusion when reading the code. Before this change one can eventually notice that "macros (uppercase symbols) are for the normal queue, lowercase operations are for the multi-level queue", but that is unnecessary friction for new developers (or existing developers just visiting this part of the codebase).
* Correct logic for setting NormalState.toplevelJames McCoy2016-09-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Vim's main_loop function, the main loop is while (!cmdwin #ifdef FEAT_CMDWIN || cmdwin_result == 0 #endif ) { ... #ifdef FEAT_EVAL /* * May perform garbage collection when waiting for a character, but * only at the very toplevel. Otherwise we may be using a List or * Dict internally somewhere. * "may_garbage_collect" is reset in vgetc() which is invoked through * do_exmode() and normal_cmd(). */ may_garbage_collect = (!cmdwin && !noexmode); #endif /* * If we're invoked as ex, do a round of ex commands. * Otherwise, get and execute a normal mode command. */ if (exmode_active) { if (noexmode) /* End of ":global/path/visual" commands */ return; do_exmode(exmode_active == EXMODE_VIM); } else normal_cmd(&oa, TRUE); } cmdwin_result is set to 0 before calling main_loop to handle the cmdwin window and gets changed when the user causes a command to execute (either through pressing <CR> or <C-c>). This means that when the cmdwin isn't active OR the user is still editing their command, main_loop runs and main_loop calls normal_cmd with toplevel true as long as exmode isn't active. When the normal mode state was extracted in dae006a9, the conditions for toplevel and may_garbage_collect were combined. Since toplevel was set to always ignore cmdwin, the v:count(1) variables were no longer being updated when a command was prefixed with a count in the cmdwin. Closes #5404
* insert_enter: Update folds on insert-leave. #5351Shougo Matsushita2016-09-18
| | | | | Fixes failing test: 045_folding_spec.lua References #5299
* refactor: eliminate misc2.cJustin M. Keyes2016-09-13
| | | | | | | | | | move `call_shell` to misc1.c Move some fns to state.c Move some fns to option.c Move some fns to memline.c Move `vim_chdir*` fns to file_search.c Move some fns to new module, bytes.c Move some fns to fileio.c
* normal.c: Restore vim-like tab dragging. #4874sach1t2016-09-12
| | | | | Closes #4663 References #3310
* Merge #3745 from cacplate/ops_WconversionJustin M. Keyes2016-06-13
|\ | | | | Enable -Wconversion in ops.c
| * remove some asserts and lintCharles Joachim2016-05-30
| |
| * ops.c: enable -Wconversion warningCharles Joachim2016-05-30
| |
* | vim-patch:7.4.1150Michael Ennen2016-06-04
| | | | | | | | | | | | | | | | | | Problem: 'langmap' applies to the first character typed in Select mode. (David Watson) Solution: Check for SELECTMODE. (Christian Brabandt, closes #572) Add the 'x' flag to feedkeys(). https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
* | *: Rename main loop variable from loop to main_loopZyX2016-05-30
|/ | | | | | | | | | | | | | | | Current name is inappropriate for the following reasons: 1. It is often masked by local `loop` variables. 2. It cannot be searched for. There are many `loop` variables where `loop` is some local variable. There are many cases when “loop” word is used in a comment. 3. It is in any case bad idea to use a generic name as a name of the global variable. Best if global has module prefix: this is why it is in `main.h`: `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”. Since I have no idea how to list every occurrence of this variable method used to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if some occurrence was hidden under false `#if` branch it was not replaced.
* vim-patch:7.4.1513Jurica Bradaric2016-05-15
| | | | | | | Problem: "J" fails if there are not enough lines. (Christian Neukirchen) Solution: Reduce the count, only fail on the last line. https://github.com/vim/vim/commit/41e0f2f48f541eb2c8eb5620d3f1d270eb979154
* vim-patch:7.4.1042Jurica Bradaric2016-05-08
| | | | | | | | Problem: g-CTRL-G shows the word count, but there is no way to get the word count in a script. Solution: Add the wordcount() function. (Christian Brabandt) https://github.com/vim/vim/commit/ed767a2073ef150971b0439a58e7ee582af6984e
* *: Fix new linter errorsZyX2016-05-01
| | | | Originally there were 128 new errors, so I thought this is a good idea to fix all of them. Of course, this commit also fixes many suppressed errors.
* normal: convert MCHAR etc operator and register types to enum MotionTypeBjörn Linse2016-05-01
|