aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark.c
Commit message (Collapse)AuthorAge
* feat(multicursor): zq operator; cursor-local marks #42148Justin M. Keyes2026-09-29
| | | | | | | | | | | | | | | | | | Problem: - `[count]Q` and `{Visual}Q` are implemented as ad hoc utils, because `Q` is not an "operator". - `Q` always "toggles", it is not "idempotent". - Various *cursor-relative* marks (`'.`, `'[`) are not saved/restored per-cursor, so they don't work during cascade. - Insert cascade clobbers the primary's `'^` and changelist. Solution: - Introduce the `zq{motion}` operator, which places cursors at every reachable `{motion}`. - `{Visual}Q` is now an alias to `{Visual}zqj`. - Introduce `1Q` and `2Q` for idempotent cursor placement. - Drop `[count]Q`, it's redundant with `zqgn`. - Classify cursor-relative marks as `type=motion` instead of `type=jump`. Save/restore per-cursor during cascade.
* fix(marks): undo reverts a mark set after the change #41330Justin M. Keyes2026-08-15
| | | | | | | | | | | | | | | | | | | | | | | | Problem: A named mark updated after a change is moved back (treated as the original mark) by undo: :1mark d :$ dw :2mark d " 'd is on line 2 :undo " 'd is back on line 1 The undo header snapshots `b_namedm` when the change is recorded, and `u_undoredo()` restores that snapshot indiscriminately. Solution: Update the pending header's snapshot when a mark is set explicitly. Marks that the change itself moved go through mark_adjust(), not setmark_pos(), so those are still reverted. Similar to 2546741d1b36 (for extmarks): an explicit set inside an undo block is confused with an edit-driven adjustment. But the extmarks case is dealing with mid-edit moves, whereas named/regular marks only need the stale snapshot dropped.
* refactor(path): pathcmp() #41035tao2026-08-07
| | | | | | | | | | | | | | | | | | | | | | Problem: Redudant code Solution: Add `path_fold_char()` to normalize path sep. Refactor `pathcmp()` and `path_fnamencmp()` into `path_cmp`. | feature | pathcmp | path_fnamencmp | path_cmp(now) | | ------------------------ | -------------- | -------------- | ------------- | | case folding | `mb_toupper()` | `utf_fold()` | `utf_fold()` | | consults fileignorecase | ✅ | ✅ | `ic` param | | `maxlen` | ✅ | ✅ | ✅ | | `/` == `\` | ✅ | ✅ | ✅ | | MSWIN drive letter | ❌ | ✅ | ✅ | | sep affects sorting | ✅ | ❌ | ✅ | | ignores a trailing slash | ✅ | ❌ | ✅ | Refactor `path_fnamecmp` and `path_full_compare` into `path_equal`, with flags controlling "no filesystem" comparison (i.e. `path_cmp`), env variables expansion, absolute path resolution and filesystem access.
* feat(marks): :marks completion, list extmarks #40743Justin M. Keyes2026-07-15
| | | | | | | | | Problem: - No UI for listing extmarks. - `:marks` doesn't support cmdline-completion. Solution: - Add completion and extmarks support to `:marks`. - Update `get_buf_local_marks` to include the ":" (prompt-buffer) mark.
* refactor(insert): rename edit.c => insert.c #40705Justin M. Keyes2026-07-12
| | | | | | | | | | Problem: - `edit.c` is an unnecessarily misleading and less-discoverable name than `insert.c`. - Numerous insert-mode related things are named with a `ins_` prefix. - There is already a `insexpand.c` module... Solution: Rename `edit.c` => `insert.c`.
* vim-patch:partial:9.2.0368: too many strlen() calls when adding strings to ↵zeertzjq2026-04-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dicts (#39237) Problem: too many strlen() calls when adding strings to dicts Solution: Refactor code to use string_T, use dict_add_string_len() instead of dict_add_string() (John Marriott) Additionally: - In textprop.c, in function prop_fill_dict() use a string_T to store local variable text_align. - In popupwin.c, use a string_T to store struct member pp_name in struct poppos_entry_T. - In mark.c, refactor function add_mark() to pass in the length of argument mname. - In insexpand.c: ->Use a string_T to store the elements of static array ctrl_x_mode_names. ->Refactor function trigger_complete_done_event(): ->->change type of argument char_u *word to string_T *word. ->->make one access of array ctrl_x_mode_names instead of two. ->Refactor function ins_compl_mode() to accept a string_T to return the resulting string. - In fileio.c: ->Refactor function getftypewfd() to accept a string_T to return the resulting string. ->In function create_readdirex_item() use a string_T to store local variable q. - In cmdexpand.c, store global cmdline_orig as a string_T. - In autocmd.c, in function f_autocmd_get() use a string_T to store local variables event_name and group_name. Measure their lengths once when they are assigned so they are not remeasured on each call to dict_add_string() in the subsequent for loop. - In channel.c, in function channel_part_info() drop local variable status and use s instead. Make s a string_T. closes: vim/vim#19999 https://github.com/vim/vim/commit/c13232699db413e735f30b5649c78a7f38a9a069 Co-authored-by: John Marriott <basilisk@internode.on.net>
* feat(events): trigger MarkSet autocmd in :delmarks #39156Ashley Hauck2026-04-19
| | | | | | | Problem: `api.nvim_buf_del_mark` already emits a `MarkSet` event with `col` and `line` set to 0. However, `:delmarks` currently emits no events. Solution: Change `:delmarks` to emit the same `col==line==0` event.
* build: update clang v21, fix warningsdundargoc2026-04-14
| | | | | - `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per `readability-uppercase-literal-suffix`
* fix(marks): make jumpoptions=view work with 'smoothscroll' (#38339)zeertzjq2026-03-17
| | | | | | Problem: 'jumpoptions' "view" doesn't remember skipcol and may lead to glitched display with 'smoothscroll'. Solution: Save skipcol in the mark view. Also make sure skipcol doesn't exceed line size.
* fix(prompt): also store column info in ': mark #36194Shadman2026-01-30
| | | | | | | | Problem: Currently, : mark is set in start of prompt-line. But more relevant location is where the user text starts. Solution: Store and update column info on ': just like the line info
* feat(events): MarkSet event, aucmd_defer() #35793Nathan Smith2025-12-07
| | | | | | | | | | | | Problem: - Can't subscribe to "mark" events. - Executing events is risky because they can't be deferred. Solution: - Introduce `MarkSet` event. - Introduce `aucmd_defer()`. Helped-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs: getpos, getregion, lspJustin M. Keyes2025-11-15
|
* fix(terminal): keep last cursor if it's on the last rowzeertzjq2025-10-29
|
* vim-patch:9.1.1885: Wrong restored cursor pos when re-entering buffer after ↵zeertzjq2025-10-29
| | | | | | | | | | | | | | changes Problem: Wrong restored cursor position when re-entering a buffer previously viewed in a window after making changes to the same buffer in another window. Solution: Adjust per-window "last cursor" positions on buffer changes. (zeertzjq) closes: vim/vim#18655 https://github.com/vim/vim/commit/b2e6b328dafe1cdfff10f1e811355e514da8071d
* fix(api): inconsistent scrolling when deleting before topline (#36301)zeertzjq2025-10-27
| | | | Problem: Inconsistent scrolling when deleting before topline with API. Solution: Only special-case inserting just before topline, not deleting.
* fix(terminal): adjust marks when deleting scrollback lines (#36294)zeertzjq2025-10-25
| | | | This also fixes inconsistent scrolling behavior on terminal output when cursor is in the middle of the buffer and the scrollback is full.
* fix(prompt_buffer): plugins can't set `':` mark #35624Shadman2025-09-08
| | | | | | | | | | Problem: Currently, prompt_buffer manages `:` mark by itself and exposes it read-only mark. However when it fails there can be no mitigation made by plugins. The `:` mark should act like a regular marks and be modifiable. Solution: Allow plugins to set `:` mark.
* refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl2025-08-14
| | | | | | | | | These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
* refactor(build): don't use the preprocessor when generating headersbfredl2025-08-06
| | | | | | | | | | | | | | Using the preprocessor before generating prototypes provides some "niceties" but the places that rely on these are pretty few. Vastly simplifying the BUILD SYSTEM is a better trade-off. Unbalancing { } blocks due to the preprocessor is cringe anyway (think of the tree-sitter trees!), write these in a different way. Add some workarounds for plattform specific features. INCLUDE_GENERATED_DECLARATIONS flag is now technically redundant, but will be cleaned up in a follow-up PR as it is a big mess.
* fix(prompt): lnum update via nvim_buf_set_lines if buf != curbuf #34833Mathias Fußenegger2025-07-07
| | | Fixes the case from https://github.com/neovim/neovim/issues/34561#issuecomment-3031536581
* vim-patch:9.1.1476: missing out-of-memory checks in cmdexpand.c (#34624)zeertzjq2025-06-24
| | | | | | | | | | | | | | | | | | | | Problem: missing out-of-memory checks in cmdexpand.c Solution: add missing out-of-memory checks, re-order code (John Marriott) This commit does the following: - in cmdline_pum_create() add out-of-memory check call of ALLOC_MULT() - in expand_cmdline() move check for out-of-memory to cover both assignments of file_str - in nextwild() don't free `p2` until after it's last use. closes: vim/vim#17592 https://github.com/vim/vim/commit/1be5b375c4446976eb5a0a90d2cfa1d2d289a6ed N/A patch: vim-patch:9.1.1474: missing out-of-memory check in mark.c Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.1467: too many strlen() calls (#34572)zeertzjq2025-06-19
| | | | | | | | | | | | | | | | | | Problem: too many strlen() calls Solution: Change expand_env() to return string length (John Marriott) This commit does the following changes: - In expand_env_esc(): - return the length of the returned dst string. - refactor to remove some calls to STRLEN() and STRCAT() - add check for out-of-memory condition. - Change call sites in various source files to use the return value closes: vim/vim#17561 https://github.com/vim/vim/commit/fff0132399082b7d012d0c1291cf0c6c99e200ff Co-authored-by: John Marriott <basilisk@internode.on.net>
* feat(prompt): multiline prompt input #33371Shadman2025-06-17
| | | | | | | | | | | | | | Problem: Cannot enter multiline prompts in a buftype=prompt buffer. Solution: - Support shift+enter (`<s-enter>`) to start a new line in the prompt. - Pasting multiline text via OS paste, clipboard, "xp, etc. - A/I in editable region works as usual. - i/a/A/I outside of editable region moves cursor to end of current prompt. - Support undo/redo in prompt buffer. - Support o/O in prompt buffer. - Expose prompt location as `':` mark.
* vim-patch:9.1.1463: Integer overflow in getmarklist() after linewise ↵zeertzjq2025-06-16
| | | | | | | | | | | operation (#34532) Problem: Integer overflow in getmarklist() after linewise operation. Solution: Don't add 1 to MAXCOL (zeertzjq) related: neovim/neovim#34524 closes: vim/vim#17552 https://github.com/vim/vim/commit/93318a9933893103442f552b26bd0a41b98cb68b
* fix(messages): "list_cmd" kind for mark commands #33874luukvbaal2025-05-06
| | | | | Problem: `:marks/jumps/changes` are missing a message kind. Solution: Assign the "list_cmd" kind to them.
* 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.
* refactor(shada): rework msgpack decoding without msgpack-cbfredl2024-08-05
| | | | | | | This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries.
* vim-patch:9.1.0554: :bw leaves jumplist and tagstack data around (#29639)zeertzjq2024-07-10
| | | | | | | | | | | | | | | | | Problem: :bw leaves jumplist and tagstack data around (Paul "Joey" Clark) Solution: Wipe jumplist and tagstack references to the wiped buffer (LemonBoy) As documented the :bwipeout command brutally deletes all the references to the buffer, so let's make it delete all the entries in the jump list and tag stack referring to the wiped-out buffer. fixes: vim/vim#8201 closes: vim/vim#15185 https://github.com/vim/vim/commit/4ff3a9b1e3ba45f9dbd0ea8c721f27d9315c4d93 Co-authored-by: LemonBoy <thatlemon@gmail.com>
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* fix(api): fix set_lines viewport adjustment, but this time goodbfredl2024-03-14
| | | | fixes #27720
* 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
* 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: eliminate cyclic includesdundargoc2023-12-20
|
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* refactor: format casting of negative number better (#26482)zeertzjq2023-12-09
|
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* build(IWYU): replace most private mappings with pragmas (#26247)zeertzjq2023-11-27
|
* refactor: enable formatting for ternariesdundargoc2023-11-20
| | | | | | This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
* refactor: follow style guidedundargoc2023-11-19
| | | | | - reduce variable scope - prefer initialization over declaration and assignment
* build: bump uncrustify versiondundargoc2023-11-19
| | | | Biggest change is that uncrustify is silent during linting.
* refactor(sign): move legacy signs to extmarksLuuk van Baal2023-11-17
| | | | | | | | | | | | | | | | | | | | Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs.
* 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.