aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
Commit message (Collapse)AuthorAge
* vim-patch:9.1.1056: Vim doesn't highlight to be inserted text when ↵zeertzjq2025-01-30
| | | | | | | | | | | | | | | | | completing (#32251) Problem: Vim doesn't highlight to be inserted text when completing Solution: Add support for the "preinsert" 'completeopt' value (glepnir) Support automatically inserting the currently selected candidate word that does not belong to the latter part of the leader. fixes: vim/vim#3433 closes: vim/vim#16403 https://github.com/vim/vim/commit/edd4ac3e895ce16034c7e098f1d68e0155d97886 Co-authored-by: glepnir <glephunter@gmail.com>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* fix(completion): avoid deleting text when completion leader changes #31448luukvbaal2024-12-06
| | | | | | | Problem: When completion leader changes, text that might be reinserted immediately after is deleted. This unnecessarily affects extmarks. #31387 restored the original extmarks but that prevents end_right_gravity marks from growing. Solution: Avoid deleting leader text that will be reinserted.
* refactor(options): autogenerate valid values and flag enums for options (#31089)Famiu Haque2024-11-23
| | | | | | | | | | | | | | Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir <glephunter@gmail.com>
* fix(paste): improve repeating of pasted text (#30438)zeertzjq2024-09-22
| | | | | | | - Fixes 'autoindent' being applied during redo. - Makes redoing a large paste significantly faster. - Stores pasted text in the register being recorded. Fix #28561
* fix(multibyte): handle backspace of wide clusters in replace modebfredl2024-09-06
| | | | | Make utf_head_off more robust against invalid sequences and embedded NUL chars
* vim-patch:9.1.0704: inserting with a count is inefficient (#30206)zeertzjq2024-09-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: inserting with a count is inefficient Solution: Disable calculation of the cursor position and topline, if a count has been used (Ken Takata) Optimize insertion when using :normal 10000ix. This patch optimizes the insertion with a large count (e.g. `:normal 10000ix`). It seems that calculation of the cursor position for a long line is slow and it takes O(n^2). Disable the calculation if not needed. Before: ``` $ time ./vim --clean -c 'normal 10000ix' -cq! real 0m1.879s user 0m1.328s sys 0m0.139s $ time ./vim --clean -c 'normal 20000ix' -cq! real 0m5.574s user 0m5.421s sys 0m0.093s $ time ./vim --clean -c 'normal 40000ix' -cq! real 0m23.588s user 0m23.187s sys 0m0.140s ``` After: ``` $ time ./vim --clean -c 'normal 10000ix' -cq! real 0m0.187s user 0m0.046s sys 0m0.093s $ time ./vim --clean -c 'normal 20000ix' -cq! real 0m0.217s user 0m0.046s sys 0m0.108s $ time ./vim --clean -c 'normal 40000ix' -cq! real 0m0.278s user 0m0.093s sys 0m0.140s $ time ./vim --clean -c 'normal 80000ix' -cq! real 0m0.494s user 0m0.311s sys 0m0.140s $ time ./vim --clean -c 'normal 160000ix' -cq! real 0m1.302s user 0m1.140s sys 0m0.094s ``` closes: vim/vim#15588 https://github.com/vim/vim/commit/09b80d23cfae24fa13ef4f52b0ec90625839a6ab Co-authored-by: Ken Takata <kentkt@csc.jp>
* feat(mbyte): support extended grapheme clusters including more emojibfredl2024-08-30
| | | | | | | | | Use the grapheme break algorithm from utf8proc to support grapheme clusters from recent unicode versions. Handle variant selector VS16 turning some codepoints into double-width emoji. This means we need to use ptr2cells rather than char2cells when possible.
* refactor: collapse statements in single assignmentsLewis Russell2024-07-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Variables are often assigned multiple places in common patterns. Solution: Replace these common patterns with different patterns that reduce the number of assignments. Use `MAX` and `MIN`: ```c if (x < y) { x = y; } // --> x = MAX(x, y); ``` ```c if (x > y) { x = y; } // --> x = MIN(x, y); ``` Use ternary: ```c int a; if (cond) { a = b; } els { a = c; } // --> int a = cond ? b : c; ```
* vim-patch:9.1.0617: Cursor moves beyond first line of folded end of buffer ↵luukvbaal2024-07-26
| | | | | | | | | | (#29859) Problem: Cursor moves beyond start of a folded range at the end of a buffer. Solution: Move cursor to start of fold when going beyond end of buffer. Check that cursor moved to detect FAIL in outer cursor function. (Luuk van Baal) https://github.com/vim/vim/commit/dc373d456b5919ed2b8f83e8642c115f646ca93d
* docs: misc (#29622)dundargoc2024-07-15
| | | | Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* revert: "refactor: use S_LEN macro" (#29319)Lewis Russell2024-06-14
| | | | | revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
* refactor: use S_LEN(s) instead of s, n (#29219)James2024-06-11
|
* vim-patch:8.2.0109: corrupted text properties when expanding spaceszeertzjq2024-06-02
| | | | | | | | | Problem: Corrupted text properties when expanding spaces. Solution: Reallocate the line. (Nobuhiro Takasaki, closes vim/vim#5457) https://github.com/vim/vim/commit/ac15fd8c6761763c8feedef1a2fbd8309f0a823c Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:8.2.0083: text properties wrong when tabs and spaces are exchangedzeertzjq2024-06-02
| | | | | | | | | | Problem: Text properties wrong when tabs and spaces are exchanged. Solution: Take text properties into account. (Nobuhiro Takasaki, closes vim/vim#5427) https://github.com/vim/vim/commit/5cb0b93d52fa5c12ca50a18509947ee6459bb7a8 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.1.0456: Left shift is incorrect with vartabstop and shiftwidth=0zeertzjq2024-06-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Left shift is incorrect with vartabstop and shiftwidth=0 Solution: make tabstop_at() function aware of shift direction (Gary Johnson) The problem was that with 'vartabstop' set and 'shiftwidth' equal 0, left shifts using << were shifting the line to the wrong column. The tabstop to the right of the first character in the line was being used as the shift amount instead of the tabstop to the left of that first character. The reason was that the tabstop_at() function always returned the value of the tabstop to the right of the given column and was not accounting for the direction of the shift. The solution was to make tabstop_at() aware of the direction of the shift and to choose the tabtop accordingly. A test was added to check this behavior and make sure it doesn't regress. While at it, also fix a few indentation/alignment issues. fixes: vim/vim#14864 closes: vim/vim#14887 https://github.com/vim/vim/commit/88d4f255b7b7a19bb4f6489e0ad0956e47d51fed Co-authored-by: Gary Johnson <garyjohn@spocom.com>
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* vim-patch:9.1.0251: Filetype test fails (#28142)zeertzjq2024-04-01
| | | | | | | | | | | | | Problem: Filetype test fails. Solution: Move detection by name before detection by extension. Improve TextChanged test and remove wrong test and fix a typo in a comment (zeertzjq). closes: vim/vim#14373 https://github.com/vim/vim/commit/8eb7523802cb51984e2202d08a4fbc1a2cd803c7 The changes to filetype.vim are N/A since Nvim always prefers filename matches to extension matches.
* vim-patch:9.1.0230: TextChanged autocommand not triggered under some ↵zeertzjq2024-04-01
| | | | | | | | | | | | | | circumstances (#28135) Problem: TextChanged autocommand not triggered under some circumstances (Sergey Vlasov) Solution: Trigger TextChanged when TextChangedI has not been triggered fixes: vim/vim#14332 closes: vim/vim#14339 https://github.com/vim/vim/commit/86032702932995db74fed265ba99ae0c823cb75d Co-authored-by: Christian Brabandt <cb@256bit.org>
* Merge pull request #28044 from luukvbaal/vim-9.1.0211zeertzjq2024-03-28
|\ | | | | vim-patch:9.1.{0211,0215}
| * vim-patch:9.1.0215: Half-page scrolling does not support smooth-scrollingLuuk van Baal2024-03-28
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Page-wise scrolling with Ctrl-D/Ctrl-U implements it's own logic to change the topline and cursor. More logic than necessary for scrolling with Ctrl-F/Ctrl-B was removed in patch 9.1.0211. Solution: Re-use the logic from Ctrl-E/Ctrl-Y/Ctrl-F/Ctrl-B while staying backward compatible as much as possible. Restore some of the logic that determined how many lines will be scrolled (Luuk van Baal) https://github.com/vim/vim/commit/5a2e3ec9ac72b6e644fea4ebba7e632498296e2f
* | vim-patch:9.1.0218: Unnecessary multiplications in backspace code (#28075)zeertzjq2024-03-28
|/ | | | | | | | | | | | Problem: Unnecessary multiplications in backspace code, as "col / ts * ts" is the same as "col - col % ts". Solution: Change "col / ts * ts" to "col - col % ts". Adjust the loop and the comments ins_bs() to be easier to understand. Update tests to reset 'smarttab' properly. (zeertzjq) closes: vim/vim#14308 https://github.com/vim/vim/commit/8ede7a069419e0e01368c65a2d0c79d6332aa6cd
* vim-patch:9.1.0204: Backspace inserts spaces with virtual text and ↵zeertzjq2024-03-26
| | | | | | | | | | | | | | 'smarttab' (#28032) Problem: Backspace inserts spaces with virtual text and 'smarttab'. Solution: Ignore virtual text and wrapping when backspacing. (zeertzjq) related: neovim/neovim#28005 closes: vim/vim#14296 https://github.com/vim/vim/commit/0185c7701434f1fbbf83fecd6384a19c1d2fc44e Co-authored-by: VanaIgr <vanaigranov@gmail.com>
* fix(edit): backspace adds extra spaces for inline virtual text (#28005)vanaigr2024-03-26
| | | | Problem: Backspace adds extra spaces for inline virtual text. Solution: Ignore virtual text and wrapping when backspacing.
* vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()zeertzjq2024-03-14
| | | | | | | | | | | | Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: vim/vim#14183 https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
* fix(api/buffer): fix handling of viewport of non-current bufferbfredl2024-03-13
| | | | | | | | | | | A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes #27723 fixes #27720
* vim-patch:9.1.0168: too many STRLEN() calls (#27823)zeertzjq2024-03-12
| | | | | | | | | | | Problem: too many STRLEN() calls Solution: Make use of ml_get_len() calls instead (John Marriott) closes: vim/vim#14123 https://github.com/vim/vim/commit/bfcc895482c717c9f6d86890d789ec739c3016b4 Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799)zeertzjq2024-03-10
| | | | | | | | | | | | | | | | Problem: too many STRLEN calls when getting a memline Solution: Optimize calls to STRLEN(), add a few functions in memline.c that return the byte length instead of relying on STRLEN() (John Marriott) closes: vim/vim#14052 https://github.com/vim/vim/commit/02d7a6c6cfceb3faf9c98fcb7c458760cd50d269 Cherry-pick line break changes from patch 8.1.0226. Cherry-pick ml_line_len from patch 8.1.0579. Cherry-pick test_comments.vim change from patch 9.1.0153. Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.0088: TextChanged not triggered for :norm! commands (#27405)zeertzjq2024-02-10
| | | | | | | | | | | | | | | | | | Problem: TextChanged not triggered for :norm! commands (machakann, after v9.0.2031) Solution: Only reset curbuf->b_last_changedtick if TextChangedI was triggered in insert mode (and not blocked) Note: for unknown reasons, the test fails on Windows (but seems to work fine when running interactively) fixes: vim/vim#13967 closes: vim/vim#13984 https://github.com/vim/vim/commit/c9e79e52845d51f48f5ea3753a62ab3fe0e40184 Cherry-pick test_autocmd.vim change from patch 8.2.4149. Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.0.1105: code is indented too much (#27314)zeertzjq2024-02-03
| | | | | | | | | | Problem: Code is indented too much. Solution: Use an early return. (Yegappan Lakshmanan, closes vim/vim#11756) https://github.com/vim/vim/commit/87c1cbbe984e60582f2536e4d3c2ce88cd474bb7 Omit free_eval_tofree_later(): Vim9 script only. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* refactor: IWYU (#27186)zeertzjq2024-01-25
|
* perf(extmarks): add metadata for efficient filtering of special decorationsbfredl2024-01-22
| | | | | | | | | | | | | | | | | | This expands on the global "don't pay for what you don't use" rules for these special extmark decorations: - inline virtual text, which needs to be processed in plines.c when we calculate the size of text on screen - virtual lines, which are needed when calculating "filler" lines - signs, with text and/or highlights, both of which needs to be processed for the entire line already at the beginning of a line. This adds a count to each node of the marktree, for how many special marks of each kind can be found in the subtree for this node. This makes it possible to quickly skip over these extra checks, when working in regions of the buffer not containing these kind of marks, instead of before where this could just be skipped if the entire _buffer_ didn't contain such marks.
* refactor: use "csarg" for CharsizeArg variables (#27123)zeertzjq2024-01-22
|
* perf: reuse fast character size calculation algorithm from getvcol()VanaIgr2024-01-22
|
* vim-patch:9.1.0035: i_CTRL-] triggers InsertCharPre (#27049)altermo2024-01-17
| | | | | | | | | | | | | | * vim-patch:9.1.0035: i_CTRL-] triggers InsertCharPre Problem: i_CTRL-] triggers InsertCharPre Solution: Return if CTRL-] is received. InsertCharPre is supposed to be only used for chars to be inserted but i_CTRL-] triggers expansion and is not inserted into the buffer (altermo) closes: vim/vim#13853 closes: vim/vim#13864 https://github.com/vim/vim/commit/7d711fe2092d0438d2df5054df735ec34926e2bc
* fix(edit): don't go to Terminal mode when stopping Insert mode (#27033)zeertzjq2024-01-16
|
* vim-patch:9.1.0022: Coverity complains about improper use of negative value ↵zeertzjq2024-01-13
| | | | | | | | | | | | | | | | | | (#27001) Problem: Coverity complains about improper use of negative value Solution: Add a condition to validate that keytyped is larger or equal to 0 Apparently patch 9.1.0006 made it more explicit for Coverity, that the TOLOWER_LOC() macros do not handle negative values properly. However, that condition has always been there even before that, so add a condition to verify that keytyped is indeed at least 0 closes: vim/vim#13824 https://github.com/vim/vim/commit/49471963fefbdf78239d9066d84e14e1876fb177 Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* vim-patch:9.1.0014: incorrect use of W_WINROW in edit.c (#26910)zeertzjq2024-01-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: incorrect use of W_WINROW in edit.c Solution: compare against curwin->w_height instead Remove incorrect use of W_WINROW In structs.h it is mentioned that w_wrow is relative to w_winrow, so using W_WINROW doesn't make sense when comparing with window height. This change won't lead to any observable behavior change: The condition intends to check if there are 'scrolloff' lines between the current cursor when the bottom of the window. When W_WINROW(curwin) is added to curwin->w_height - 1 - get_scrolloff_value(), the condition is instead satisfied when the cursor is on some screen line below that position. However, - If 'scrolloff' is smaller than half the window height, this condition can only be satisfied when W_WINROW(curwin) == 0. And if it is not satisfied, update_topline() does the actual scrolling. - If 'scrolloff' is larger than half the window height, update_topline() will put the cursor at the center of the window soon afterwards anyway, because set_topline() now unsets VALID_TOPLINE flag starting from https://github.com/vim/vim-history/commit/7db7bb45b0f919ff0615d463ebd4fde881c69d1f. To put it in another way, https://github.com/vim/vim-history/commit/7db7bb45b0f919ff0615d463ebd4fde881c69d1f makes the update_topline() just below correct the mistakes made in this block, so this incorrect use of W_WINROW() no longer affects observable behavior. closes: vim/vim#12331 https://github.com/vim/vim/commit/b1ed7ec9f7d1a0142d4f1c8c83bab9172bc92c7c
* refactor: remove redundant struct namesdundargoc2024-01-02
| | | | A struct can be anonymous if only its typedef is used.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq2023-12-21
|
* docs: add style rule regarding initializationdundargoc2023-12-18
| | | | | Specifically, specify that each initialization should be done on a separate line.
* vim-patch:9.0.2145: wrong scrolling in insert mode with smoothscroll (#26375)zeertzjq2023-12-04
| | | | | | | | | | Problem: Wrong scrolling in Insert mode with 'smoothscroll' at the bottom of the window. Solution: Don't use set_topline() when 'smoothscroll' is set. fixes: vim/vim#13612 closes: vim/vim#13613 https://github.com/vim/vim/commit/5b4d1fcbf06757bae32a894871b9a649c84eba7f
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|