aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
Commit message (Collapse)AuthorAge
* docs: miscdundargoc2025-01-30
| | | | | | | | | Co-authored-by: Dustin S. <dstackmasta27@gmail.com> Co-authored-by: Ferenc Fejes <fejes@inf.elte.hu> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: brianhuster <phambinhanctb2004@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* fix(ui): avoid redundant ext_cmdline events (#32237)luukvbaal2025-01-29
| | | | | | | | Problem: `cmdline_show` is emitted unnecessarily each event loop iteration, because `cmdline_was_last_drawn` is never set. Solution: Keep track of whether the cmdline was last drawn to avoid unnecessarily emitting cmdline_show. Set `redraw_state` to emit `cmdline_pos` when emitting `CursorMovedC`. Only emit `cmdline_pos` when cmdline was last drawn.
* feat(inccommand): preview 'nomodifiable' buffers #32034Donatas2025-01-20
| | | | | | | | Problem: Incremental preview is not allowed on 'nomodifiable' buffers. Solution: - Allow preview on 'nomodifiable' buffers. - Restore the 'modifiable' option in case the preview function changes it.
* refactor(cmdline): more idiomatic way to avoid cmdline_showLuuk van Baal2025-01-17
| | | | | Problem: Fix applied in #32033 can be more idiomatic. Solution: Unset redraw_state instead of cmdbuff.
* fix(cmdline): prevent cmdline_show events after exiting cmdline #32033luukvbaal2025-01-15
| | | | | | Problem: If a (vim.ui_attach) cmdline_hide callback triggers a redraw, it may cause cmdline_show events for an already exited cmdline. Solution: Avoid emitting cmdline_show event when ccline.cmdbuff is already NULL. Unset ccline.cmdbuff before emitting cmdline_hide.
* fix: fix incorrect search codedundargoc2025-01-06
|
* fix(cmdline): always show cmdline when it is a prompt #31866luukvbaal2025-01-05
| | | Cmdline prompts should ignore `cmd_silent`.
* feat(ui)!: emit prompt "messages" as cmdline events #31525luukvbaal2025-01-02
| | | | | | | Problem: Prompts are emitted as messages events, where cmdline events are more appropriate. The user input is also emitted as message events in fast context, so cannot be displayed with vim.ui_attach(). Solution: Prompt for user input through cmdline prompts.
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* Merge #31661 cmdline_show/hide eventsJustin M. Keyes2024-12-22
|\
| * feat(ui): additional arguments for cmdline_show/hide eventsLuuk van Baal2024-12-22
| | | | | | | | | | | | | | | | Problem: Unable to tell what highlight the prompt part of a cmdline_show event should have, and whether cmdline_hide was emitted after aborting. Solution: Add additional arguments hl_id to cmdline_show, and abort to cmdline_hide.
* | fix(messages): typo and unwanted truncation in msg_outtrans_long #31669luukvbaal2024-12-22
|/ | | | | | | | | | - Typo/bug in msg_outtrans_long passing string length as "hist" argument. - Avoid truncating message in msg_outtrans_long with ext_messages (followup to 1097d239c307a10a87fa995c4cfbe5987939e177). - Remove `_hl` from `msg_keep`, `smsg_keep` as there is no non-`_hl` variant. - `msg_printf_hl` is removed (identical to `smsg` except it sets `msg_scroll = true`, seemingly as a caveat to force a more prompt in cmdline mode). Move this logic to the only the only place this was used in ex_getln.c.
* refactor(api): always use TRY_WRAP #31600luukvbaal2024-12-17
| | | | | | | Problem: Two separate try/end wrappers, that only marginally differ by restoring a few variables. Wrappers that don't restore previous state are dangerous to use in "api-fast" functions. Solution: Remove wrappers that don't restore the previous state. Always use TRY_WRAP.
* fix(ui): update title in more cases (#31508)zeertzjq2024-12-10
|
* 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.
* Merge pull request #27813 from luukvbaal/msgidbfredl2024-11-11
|\ | | | | feat(ext_messages): add hl_id to ext_messages chunks
| * 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(cmdline): simplify and correct grapheme cluster adjustmentbfredl2024-11-08
| |
* | fix(inccommand): ensure cursor is where it belongsLuuk van Baal2024-11-07
|/ | | | | Problem: Inccommand preview callback may flush inaccurate cmdline cursor position. Solution: Ensure cursor is where it belongs when doing command preview.
* vim-patch:9.1.0798: too many strlen() calls in cmdhist.c (#30895)zeertzjq2024-10-22
| | | | | | | | | | | Problem: too many strlen() calls in cmdhist.c Solution: refactor code and remove strlen() calls (John Marriott) closes: vim/vim#15888 https://github.com/vim/vim/commit/8df07d0ca310a55e1540f7d234b536abee49abd4 Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.0770: current command line completion is a bit limited (#30728)zeertzjq2024-10-09
| | | | | | | | | | | Problem: current command completion is a bit limited Solution: Add the shellcmdline completion type and getmdcomplpat() function (Ruslan Russkikh). closes: vim/vim#15823 https://github.com/vim/vim/commit/0407d621bbad020b840ffbbbd25ba023bbc05edd Co-authored-by: Ruslan Russkikh <dvrussk@yandex.ru>
* vim-patch:9.1.0766: too many strlen() calls in ex_getln.c (#30715)zeertzjq2024-10-08
| | | | | | | | | | | Problem: too many strlen() calls in ex_getln.c Solution: refactor the code to reduce the number of strlen() calls (John Marriott) closes: vim/vim#15809 https://github.com/vim/vim/commit/ccf8907570e14396e265b742e51f5089fdf97bf5 Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.0752: can set 'cedit' to an invalid value (#30616)zeertzjq2024-10-01
| | | | | | | | | | | Problem: can set cedit to an invalid value Solution: Check that the value is a valid key name (Milly) closes: vim/vim#15778 https://github.com/vim/vim/commit/25732435c56d762abb260499680939bd8882c708 Co-authored-by: Milly <milly.ca@gmail.com>
* vim-patch:9.1.0742: getcmdprompt() implementation can be improvedzeertzjq2024-09-26
| | | | | | | | | | | Problem: getcmdprompt() implementation can be improved Solution: Improve and simplify it (h-east) closes: vim/vim#15743 https://github.com/vim/vim/commit/25876a6cdd439054d0b3f920ccca0a435481de15 Co-authored-by: h-east <h.east.727@gmail.com>
* vim-patch:9.1.0741: No way to get prompt for input()/confirm()zeertzjq2024-09-26
| | | | | | | | | | | | Problem: No way to get prompt for input()/confirm() Solution: add getcmdprompt() function (Shougo Matsushita) (Shougo Matsushita) closes: vim/vim#15667 https://github.com/vim/vim/commit/6908428560a0d6ae27bf7af6fcb6dc362e31926c Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
* vim-patch:9.1.0739: [security]: use-after-free in ex_getln.c (#30448)zeertzjq2024-09-21
| | | | | | | | | | Problem: [security]: use-after-free in ex_getln.c Solution: free pointer p a bit later (John Marriott) closes: vim/vim#15712 https://github.com/vim/vim/commit/a6de28755ec3fcc86d1ed0b744f1b410a8e9702d Co-authored-by: John Marriott <basilisk@internode.on.net>
* 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: move some functions out of eval.c (#29964)zeertzjq2024-08-02
| | | | | | - common_function() has always been in evalfunc.c in Vim - return_register() has always been in evalfunc.c in Vim - get_user_input() was moved to ex_getln.c in Vim 8.1.1957 - tv_get_lnum_buf() was moved to typval.c in Vim 8.2.0847
* 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.0543: Behavior of CursorMovedC is strange (#29608)zeertzjq2024-07-08
| | | | | | | | | | Problem: Behavior of CursorMovedC is strange. Solution: Also trigger when the cmdline has changed. (zeertzjq) fixes: vim/vim#15069 closes: vim/vim#15071 https://github.com/vim/vim/commit/8145620a958dbb5c82cf8f8a37556ee1ea501c6d
* vim-patch:9.1.0511: CursorMovedC triggered wrongly with setcmdpos()zeertzjq2024-06-21
| | | | | | | | | | | Problem: CursorMovedC triggered wrongly with setcmdpos() (after v9.1.0507) Solution: Remove the premature triggering. Also don't trigger when cursor didn't move. (zeertzjq) closes: vim/vim#15064 https://github.com/vim/vim/commit/bc6f96708e3678dbb27ec4192d87cf94a15d4e9a
* vim-patch:9.1.0507: hard to detect cursor movement in the command linezeertzjq2024-06-21
| | | | | | | | | | | | Problem: hard to detect cursor movement in the command line Solution: Add the CursorMovedC autocommand (Shougo Matsushita) closes: vim/vim#15040 https://github.com/vim/vim/commit/d09521476f41dd8dbddb25b7acd0b299f9bf94d3 Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
* vim-patch:9.1.0498: getcmdcompltype() interferes with cmdline completion ↵zeertzjq2024-06-19
| | | | | | | | | | | (#29397) Problem: getcmdcompltype() interferes with cmdline completion. Solution: Don't set expand context when it's already set. (zeertzjq) closes: vim/vim#15036 https://github.com/vim/vim/commit/a821b609f9bb9daef032fe1cb8fb95995822e367
* 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
|
* fix(ui): superfluous showmode / excessive grid_cursor_goto #29089luukvbaal2024-06-04
| | | | | | | | | Problem: Unsetting global variables earlier in #28578 to avoid recursiveness, caused superfluous or even unlimited showmode(). Solution: Partly revert #28578 so that the globals are unset at the end of showmode(), and avoid recursiveness for ext UI by adding a recursive function guard to each generated UI call that may call a Lua callback.
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* fix(ui): flush ext_cmdline events before doing cmdpreview #27950luukvbaal2024-05-28
| | | | Problem: Unable to update the screen for external cmdline during cmdpreview. Solution: Flush the cmdline UI before cmdpreview state.
* vim-patch:9.1.0426: too many strlen() calls in search.czeertzjq2024-05-22
| | | | | | | | | | | | | Problem: too many strlen() calls in search.c Solution: refactor code and remove more strlen() calls, use explicit variable to remember strlen (John Marriott) closes: vim/vim#14796 https://github.com/vim/vim/commit/8c85a2a49acf80e4f53ec51e6ff2a5f3830eeddb Co-authored-by: John Marriott <basilisk@internode.on.net>
* fix(ui): avoid recursiveness and invalid memory access #28578luukvbaal2024-05-01
| | | | | | | | Problem: Calling :redraw from vim.ui_attach() callback results in recursive cmdline/message events. Solution: Avoid recursiveness where possible and replace global "call_buf" with separate, temporary buffers for each event so that when a Lua callback for one event fires another event, that does not result in invalid memory access.
* fix(lua): vim.fn.has('nvim-0.10') in fast context, used by vim.deprecatebfredl2024-04-25
|
* vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308)zeertzjq2024-04-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: vim/vim#13704 https://github.com/vim/vim/commit/6fdb6280821a822768df5689a5d727e37d38306c Co-authored-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com>
* refactor(options): remove `set_string_option_direct()`Famiu Haque2024-03-21
| | | | | | Problem: `set_string_option_direct()` contains a separate codepath specifically for setting string options. Not only is that unnecessary code duplication, but it's also limited to only string options. Solution: Replace `set_string_option_direct()` with `set_option_direct()` which calls `set_option()` under the hood. This reduces code duplication and allows directly setting an option of any type.
* fix(cmdline): wrong 'incsearch' highlighting after :redraw (#27947)luukvbaal2024-03-20
| | | | Problem: Calling :redraw from a timer callback clears 'incsearch' highlighting. Solution: Re-apply 'incsearch' highlighting if the screen was updated.
* fix(ui): ext_cmdline should not move cursor to curwinLuuk van Baal2024-03-15
| | | | | | | | | | | Problem: The ext_cmdline cursor position on the screen seems to rely on an implicit assumption that the event listener implements a cmdline window that is made the current window which is problematic (e.g. breaks 'incsearch' in the actual current window). Solution: Remove this assumption and allow nvim_win_set_cursor() to move the cursor on the screen to a non-current window (previous commit).
* 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.0137: <Del> in cmdline mode doesn't delete composing chars ↵zeertzjq2024-02-27
| | | | | | | | | | (#27636) Problem: <Del> in cmdline mode doesn't delete composing chars Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq) closes: vim/vim#14095 https://github.com/vim/vim/commit/ff2b79d23956263ab0120623c37e0b4498be01db
* fix(mbyte): fix bugs in utf_cp_*_off() functionsVanaIgr2024-02-26
| | | | | | Problems: - Illegal bytes after valid UTF-8 char cause utf_cp_*_off() to fail. - When stream isn't NUL-terminated, utf_cp_*_off() may go over the end. Solution: Don't go over end of the char of end of the string.
* 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>