aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/change.c
Commit message (Collapse)AuthorAge
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* 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>
* refactor(highlight): make enum of builtin highlights start with 1bfredl2024-11-13
| | | | | This makes it possible to use HLF_ values directly as highlight id:s and avoids +1 adjustments especially around messages.
* refactor(message): propagate highlight id instead of attrsLuuk van Baal2024-11-08
| | | | | | | Problem: Highlight group id is not propagated to the end of the message call stack, where ext_messages are emitted. Solution: Refactor message functions to pass along highlight group id instead of attr id.
* 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
* 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:8.2.5047: CurSearch highlight is often wrongzeertzjq2024-06-19
| | | | | | | | | Problem: CurSearch highlight is often wrong. Solution: Remember the last highlighted position and redraw when needed. https://github.com/vim/vim/commit/368137aa525982984beed73940af481ac53a62af Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(memory): use builtin strcat() instead of STRCAT()bfredl2024-06-11
| | | | | | | | The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
* refactor(change): check all tabpages in changed_lines_invalidate_buf() (#28666)zeertzjq2024-05-08
| | | | | This most likely doesn't matter as all windows are redrawn when switching tabpages and w_valid is reset is entering window, but still check all tabpages for consistency with changed_common().
* refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq2024-04-20
| | | | | | Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
* vim-patch:9.1.0280: several issues with 'smoothscroll' supportLuuk van Baal2024-04-09
| | | | | | | | | | Problem: Logic to make sure cursor is in visible part of the screen after scrolling the text with 'smoothscroll' is scattered, asymmetric and contains bugs. Solution: Adjust and create helper function for 'smoothscroll' cursor logic. (Luuk van Baal) https://github.com/vim/vim/commit/9148ba8a46baa3934c44164989cdcdec5d01d9e3
* vim-patch:9.1.0258: half-page scrolling broke backward compatibilityLuuk van Baal2024-04-08
| | | | | | | | | | | Problem: Support for 'smoothscroll' in (half-)page scrolling broke backward compatibility and can be made to work better. (after v9.1.215) Solution: Restore the previous cursor and end-of-buffer behavior for half-page scrolling and improve 'smoothscroll' support. (Luuk van Baal) https://github.com/vim/vim/commit/cb204e688e5c9d56a78b621ef27c35d91860cb09
* test: use matches(...) instead of ok(string.find(...)) (#28111)zeertzjq2024-03-30
|
* fix(extmarks): splice earlier when opening new line (#28108)zeertzjq2024-03-30
| | | | Related #26364 #26499 #26501 Fix #28107
* 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:8.2.4944: text properties are wrong after "cc" (#27821)zeertzjq2024-03-12
| | | | | | | | | Problem: Text properties are wrong after "cc". (Axel Forsman) Solution: Pass the deleted byte count to inserted_bytes(). (closes vim/vim#10412, closes vim/vim#7737, closes vim/vim#5763) https://github.com/vim/vim/commit/d0b1a09f44654bb5e29b09de1311845200f17d90 Co-authored-by: LemonBoy <thatlemon@gmail.com>
* 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>
* perf(redraw): reduce redraw with undo and extmarks or 'spell' (#27442)zeertzjq2024-02-13
| | | | | | | | | | | | | | | | vim-patch:9.1.0100: Redrawing can be improved with undo and 'spell' Problem: When undoing with 'spell', redrawWinline() is called after changed_lines(), while later win_update() sets redraw type to UPD_NOT_VALID, even though w_redraw_top and w_redraw_bot are still valid. Solution: Only set redraw type to UPD_NOT_VALID when inserting/deleting lines after parts of window has pending redraw, i.e., when changed_lines() is called after redrawWinline(). (zeertzjq) closes: vim/vim#14019 https://github.com/vim/vim/commit/f2d90a351159fd6843f450850f52004f42e00183
* vim-patch:9.0.0245: mechanism to prevent recursive screen updating is ↵zeertzjq2024-02-13
| | | | | | | | | | | incomplete (#27448) Problem: Mechanism to prevent recursive screen updating is incomplete. Solution: Add "redraw_not_allowed" and set it in build_stl_str_hl(). (issue vim/vim#10952) https://github.com/vim/vim/commit/471c0fa3eed4f6207d1cb7636970547bfd2eee26 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* perf(extmarks): avoid unnecessary invalidations for virt_text (#27435)zeertzjq2024-02-12
| | | | Invalidation of most w_valid flags isn't needed when adding or removing virtual text below cursor.
* refactor(indent): refactor computing of a string's indent size (#27252)VanaIgr2024-02-12
| | | | | | | | | | | | | | | | | | The `get_indent_str_vtab()` function currently calls `tabstop_padding()` every time a tab is encountered (unless tabstops aren't used). `tabstop_padding()` either does a division by 'tabstop' If 'vartabstop' is not set, or iterates through the 'vartabstop' list to find current tab width. Since the virtual column only increases, we can keep track of where the next tabstop would be, and update this information once it was reached. `get_indent_str_vtab()` also depends on 'listchars' "tab" value from the current window, even though it may be called for a line from the same buffer in a different window. In most cases, it is called with tabstops enabled (last argument was `false`), so I split the function into one that uses tabstops and the other that doesn't. I removed `get_indent_str()` since I couldn't find any calls to it.
* vim-patch:9.1.0082: Redrawing can be improved when deleting lines with ↵zeertzjq2024-02-08
| | | | | | | | | | | | | | 'cursorline' Problem: Redrawing can be improved when deleting lines with 'cursorline'. Solution: Use smarter invalidation and adjustment. Remove unnecessary UPD_VALID as it is already set at the top of the loop. Make the test for vim/vim#4862 fail without the fix. (zeertzjq) closes: vim/vim#13986 https://github.com/vim/vim/commit/7ce34c9a947b17a8b5e81e7c2335a63552182d10
* 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(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.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq2023-12-21
|
* refactor: eliminate cyclic includesdundargoc2023-12-20
|
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* docs: add style rule regarding initializationdundargoc2023-12-18
| | | | | Specifically, specify that each initialization should be done on a separate line.
* fix(change): update fold after on_bytes (#26364)Jaehwang Jung2023-12-05
| | | | | | | | | | | | | | | | | | | | | | | | Problem: With vim.treesitter.foldexpr, `o`-ing two lines above a folded region opens the fold. This does not happen with legacy foldexprs. For example, make a markdown file with the following text (without indentation), enable treesitter fold, and follow the instruction in the text. put cursor on this line and type zoo<Esc> initially folded, revealed by zo # then this fold will be opened initially folded, revealed by o<Esc> Analysis: * `o` updates folds first (done in `changed_lines`), evaluating foldexpr, and then invokes `on_bytes` (done in `extmark_splice`). * Treesitter fold allocates the foldinfo for added lines (`add_range`) on `on_bytes`. * Therefore, when treesitter foldexpr is invoked while running `o`, it sees outdated foldinfo. Solution: `extmark_splice`, and then `changed_lines`. This seems to be the standard order in other places, e.g., `nvim_buf_set_lines`.
* 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
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* build: rework IWYU mapping filesdundargoc2023-11-25
| | | | | Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU.
* refactor(grid): make screen rendering more multibyte than ever beforebfredl2023-11-17
| | | | | | | | | | | | | | | | | | Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes.
* vim-patch:9.0.2107: [security]: FPE in adjust_plines_for_skipcol (#26082)zeertzjq2023-11-17
| | | | | | | | | | | | | Problem: [security]: FPE in adjust_plines_for_skipcol Solution: don't divide by zero, return zero Prevent a floating point exception when calculating w_skipcol (which can happen with a small window when the number option is set and cpo+=n). Add a test to verify https://github.com/vim/vim/commit/cb0b99f0672d8446585d26e998343dceca17d1ce Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor: follow style guidedundargoc2023-11-13
| | | | | | - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* refactor: remove redundant castsdundargoc2023-11-11
|
* refactor: the long goodbyedundargoc2023-11-05
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* refactor: the long goodbyedundargoc2023-10-09
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* refactor: the long goodbyedundargoc2023-10-03
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
* fix(extmarks): wrong display when changing text with virt_lines (#24879)Ibby2023-08-26
|