summaryrefslogtreecommitdiffstats
path: root/src/ex_getln.c
AgeCommit message (Collapse)Author
2024-01-23patch 9.1.0049: Make "[Command Line]" a special buffer namev9.1.0049Sean Dewar
Problem: E95 is possible if a buffer called "[Command Line]" already exists when opening the cmdwin. This can also happen if the cmdwin's buffer could not be deleted when closing. Solution: Un-name the cmdwin buffer, and give it a special name instead, similar to what's done for quickfix buffers and for unnamed prompt and scratch buffers. As a result, BufFilePre/Post are no longer fired when opening the cmdwin. Add a "command" key to the dictionary returned by getbufinfo() to differentiate the cmdwin buffer instead. (Sean Dewar) NOTE: This is technically a breaking change... maybe this needs a different solution? (Or maybe this issue can be ignored...) A GitHub search reveals some plugins expect the old behaviour. However, many of those plugins also do not seem to account for the string being translated, so they are subtly broken anyway (not withstanding the fact that you can call any old buffer "[Command Line]" too...) closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-23patch 9.1.0048: Abort opening cmdwin if autocmds screw things upv9.1.0048Sean Dewar
Problem: Autocmds triggered from opening the cmdwin (in win_split and do_ecmd) can cause issues such as E199, as the current checks are insufficient. Solution: Commands executed from the cmdwin apply to the old curwin/buf, so they should be kept in a "suspended" state; abort if they've changed. Also abort if cmdwin/buf was tampered with, and check that curwin is correct. Try to clean up the cmdwin buffer (only if hidden and non-current to simplify things; the same approach is used when closing cmdwin normally), and add a beep. (Sean Dewar) It'd be nice to also check that curwin was *really* created by win_split, as autocommands can change curwin before it returns (so it can't be assumed to be that of the split); for now, this means that the cmdwin may not be the botwin in that case, which is probably OK. closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-23patch 9.1.0047: issues with temp curwin/buf while cmdwin is openv9.1.0047Sean Dewar
Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Alternatively, we could ban win_execute in the cmdwin and audit all places that temporarily change/restore curwin/buf, but I didn't notice any problems arising from allowing this (standard cmdwin restrictions still apply, so things that may actually break the cmdwin are still forbidden). closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-19patch 9.0.2180: POSIX function name in exarg causes issuesv9.0.2180Zoltan Arpadffy
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: #13704 Signed-off-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-27patch 9.0.2133: Cannot detect overstrike mode in Cmdline modev9.0.2133Sam-programs
Problem: Cannot detect overstrike mode in Cmdline mode Solution: Make mode() return "cr" for overstrike closes: #13569 Signed-off-by: Sam-programs <None> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-26patch 9.0.2068: [security] overflow in :historyv9.0.2068Christian Brabandt
Problem: [security] overflow in :history Solution: Check that value fits into int The get_list_range() function, used to parse numbers for the :history and :clist command internally uses long variables to store the numbers. However function arguments are integer pointers, which can then overflow. Check that the return value from the vim_str2nr() function is not larger than INT_MAX and if yes, bail out with an error. I guess nobody uses a cmdline/clist history that needs so many entries... (famous last words). It is only a moderate vulnerability, so impact should be low. Github Advisory: https://github.com/vim/vim/security/advisories/GHSA-q22m-h7m2-9mgm Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-17patch 9.0.2037: A few remaining cmdline completion issues with C-E/Yv9.0.2037Yee Cheng Chin
Problem: A few remaining cmdline completion issues with C-E/Y Solution: Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end A few places in the cmdline completion code only works properly when the user hits Tab (or 'wildchar') at the end of the cmdline, even though it's supposed to work even in the middle of the line. For fuzzy search, `:e ++ff`, and `:set hl=`, fix completion code to make sure to use `xp_pattern_len` instead of assuming the entire `xp_pattern` is the search pattern (since it contains texts after the cursor). Fix Ctrl-E / Ctrl-Y to not jump to the end when canceling/accepting a wildmenu completion. Also, make them work even when not using `set wildoptions+=pum` as there is no drawback to doing so. (Related issue where this was brought up: #13331) closes: #13362 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-17patch 9.0.2035: [security] use-after-free with wildmenuv9.0.2035Yee Cheng Chin
Problem: [security] use-after-free with wildmenu Solution: properly clean up the wildmenu when exiting Fix wildchar/wildmenu/pum memory corruption with special wildchar's Currently, using `wildchar=<Esc>` or `wildchar=<C-\>` can lead to a memory corruption if using wildmenu+pum, or wrong states if only using wildmenu. This is due to the code only using one single place inside the cmdline process loop to perform wild menu clean up (by checking `end_wildmenu`) but there are other odd situations where the loop could have exited and we need a post-loop clean up just to be sure. If the clean up was not done you would have a stale popup menu referring to invalid memory, or if not using popup menu, incorrect status line (if `laststatus=0`). For example, if you hit `<Esc>` two times when it's wildchar, there's a hard-coded behavior to exit command-line as a failsafe for user, and if you hit `<C-\><C-\><C-N>` it will also exit command-line, but the clean up code would not have hit because of specialized `<C-\>` handling. Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also used for 'wildchar'/'wildcharm'. Currently they don't behave properly, and also have potentially memory unsafe behavior as the logic is currently not accounting for this situation and try to do both. (Previous patch that addressed this: #11677) Also, correctly document Escape key behavior (double-hit it to escape) in wildchar docs as it's previously undocumented. In addition, block known invalid chars to be set in `wildchar` option, such as Ctrl-C and `<CR>`. This is just to make it clear to the user they shouldn't be set, and is not required for this bug fix. closes: #13361 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-09-29patch 9.0.1958: cannot complete option valuesv9.0.1958Yee Cheng Chin
Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=<Tab>` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: #13182 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-08-27patch 9.0.1795: Indentation issuesv9.0.1795Yegappan Lakshmanan
Problem: Indentation issues Solution: Fix code indentation issues. closes: #12906 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-20patch 9.0.1774: no support for custom cmdline completionv9.0.1774Shougo Matsushita
Problem: no support for custom cmdline completion Solution: Add new vimscript functions Add the following two functions: - getcmdcompltype() returns custom and customlist functions - getcompletion() supports both custom and customlist closes: #12228 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2023-08-19patch 9.0.1744: Dead code in open_cmdwin()v9.0.1744Sean Dewar
Problem: Dead code in open_cmdwin() Solution: Remove it closes: #12839 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
2023-08-11patch 9.0.1691: wrong viewport restored for incsearch and smoothscrollv9.0.1691zeertzjq
Problem: wrong viewport restored for incsearch and smoothscroll Solution: Save and restore skipcol as well closes: #12713 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-05-29patch 9.0.1588: Incsearch not triggered when pasting clipboard registerv9.0.1588K.Takata
Problem: Incsearch not triggered when pasting clipboard register on the command line. Solution: Also set "literally" when using a clipboard register. (Ken Takata, closes #12460)
2023-05-20patch 9.0.1571: RedrawingDisabled not used consistentlyv9.0.1571Bram Moolenaar
Problem: RedrawingDisabled not used consistently. Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in win_split_ins(). (closes #11961)
2023-05-13patch 9.0.1550: in cmdline window S-Tab does not select previous completionv9.0.1550Bram Moolenaar
Problem: In cmdline window S-Tab does not select previous completion. (Maxim Kim) Solution: Add a mappint for S-Tab. (closes #12116)
2023-04-17patch 9.0.1460: insufficient testing for getcmdcompltype()v9.0.1460zeertzjq
Problem: Insufficient testing for getcmdcompltype(). Solution: Add a few more test cases. (closes #12268)
2023-04-12patch 9.0.1444: crash when passing NULL to setcmdline()v9.0.1444zeertzjq
Problem: Crash when passing NULL to setcmdline(). (Andreas Louv) Solution: Use tv_get_string() instead of using v_string directly. (closes #12231, closes #12227)
2023-03-04patch 9.0.1380: CTRL-X on 2**64 subtracts twov9.0.1380Bram Moolenaar
Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes #12103)
2023-02-20patch 9.0.1330: handling new value of an option has a long "else if" chainv9.0.1330Yegappan Lakshmanan
Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes #12015)
2023-02-11patch 9.0.1299: change for triggering incsearch not sufficiently testedv9.0.1299zeertzjq
Problem: Change for triggering incsearch not sufficiently tested. Solution: Add a test case. Simplify the code. (closes #11971)
2023-02-10patch 9.0.1298: inserting register on the cmdline does not trigger incsearchv9.0.1298K.Takata
Problem: Inserting a register on the command line does not trigger incsearch or update hlsearch. Solution: Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate and handle it correctly. (Ken Takata, closes #11960)
2023-02-06patch 9.0.1290: CTRL-N and -P on cmdline don't trigger CmdlineChangedv9.0.1290zeertzjq
Problem: CTRL-N and -P on cmdline don't trigger CmdlineChanged. Solution: Jump to cmdline_changed instead of cmdline_not_changed. (closes #11956)
2023-01-09patch 9.0.1166: code is indented more than necessaryv9.0.1166Yegappan Lakshmanan
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11792)
2023-01-02patch 9.0.1132: code is indented more than neededv9.0.1132Yegappan Lakshmanan
Problem: Code is indented more than needed. Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan, closes #11769)
2022-12-30patch 9.0.1115: code is indented more than neededv9.0.1115Yegappan Lakshmanan
Problem: Code is indented more than needed. Solution: Use an early return to reduce indenting. (Yegappan Lakshmanan, closes #11758)
2022-12-09patch 9.0.1040: test for <Cmd> mapping with CmdlineChanged failsv9.0.1040Bram Moolenaar
Problem: Test for <Cmd> mapping with CmdlineChanged fails. Solution: Put back the check for the cmdline length not changing.
2022-12-09patch 9.0.1039: using a <Cmd> mapping CmdlineChanged may be triggered twicev9.0.1039Bram Moolenaar
Problem: Using a <Cmd> mapping CmdlineChanged may be triggered twice. Solution: Count the number of times CmdlineChanged is triggered and avoid doing it twice. (closes #116820
2022-12-09patch 9.0.1038: function name does not match what it is used forv9.0.1038zeertzjq
Problem: Function name does not match what it is used for. Solution: Include the modifier in the name. (closes #11679)
2022-12-01patch 9.0.0980: the keyboard state response may end up in a shell commandv9.0.0980Bram Moolenaar
Problem: The keyboard state response may end up in a shell command. Solution: Only request the keyboard protocol state when the typeahead is empty, no more commands are following and not exiting. Add the t_RK termcap entry for this.
2022-11-17patch 9.0.0892: may redraw when not neededv9.0.0892Bram Moolenaar
Problem: May redraw when not needed, causing slow scrolling. Solution: Do not redraw when w_skipcol doesn't change. When w_skipcol changes only redraw from the top. (issue #11559)
2022-11-15patch 9.0.0886: horizontal mouse scroll only works in the GUIv9.0.0886Christopher Plewright
Problem: Horizontal mouse scroll only works in the GUI. Solution: Make horizontal mouse scroll also work in a terminal. (Christopher Plewright, closes #11448)
2022-10-04patch 9.0.0657: too many #ifdefsv9.0.0657Martin Tournoij
Problem: Too many #ifdefs. Solution: Graduate the +cmdwin feature. Now the tiny and small builds are equal, drop the small build. (Martin Tournoij, closes #11268)
2022-09-18patch 9.0.0500: when quitting cmdline window with CTRL-C it remains visiblev9.0.0500Bram Moolenaar
Problem: When quitting the cmdline window with CTRL-C it remains visible. Solution: Redraw to avoid confusion. Adjust the error message. (closes #11152) Adjust the cursor position after CTRL-C.
2022-09-17patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmdv9.0.0490Bram Moolenaar
Problem: Using freed memory with cmdwin and BufEnter autocmd. Solution: Make sure pointer to b_p_iminsert is still valid.
2022-09-15patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is offv9.0.0469Luuk van Baal
Problem: Cursor moves if cmdwin is closed when 'splitscroll' is off. Solution: Skip win_fix_cursor if called when cmdwin is open or closing. (Luuk van Baal, closes #11134)
2022-09-14patch 9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is offv9.0.0465mityu
Problem: Cursor moves when cmdwin is closed when 'splitscroll' is off. Solution: Temporarily set 'splitscroll' when jumping back to the original window. (closes #11128)
2022-09-11patch 9.0.0447: using :echowin while at the hit-enter prompt causes problemsv9.0.0447Bram Moolenaar
Problem: Using :echowin while at the hit-enter prompt causes problems. Solution: Do not prompt for :echowin. Postpone showing the message window. Start the timer when the window is displayed.
2022-08-31patch 9.0.0340: the 'cmdheight' zero support causes too much troublev9.0.0340Bram Moolenaar
Problem: The 'cmdheight' zero support causes too much trouble. Solution: Revert support for 'cmdheight' being zero.
2022-08-29patch 9.0.0321: cannot use the message popup window directlyv9.0.0321Bram Moolenaar
Problem: Cannot use the message popup window directly. Solution: Add ":echowindow".
2022-08-29patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()v9.0.0320zeertzjq
Problem: Command line type of CmdlineChange differs from getcmdtype(). Solution: Use the same type. (closes #11005)
2022-08-29patch 9.0.0318: clearing screen causes flickerv9.0.0318Bram Moolenaar
Problem: Clearing screen causes flicker. Solution: Do not clear but redraw in more cases. Add () to "wait_return".
2022-08-29patch 9.0.0316: screen flickers when 'cmdheight' is zerov9.0.0316Bram Moolenaar
Problem: Screen flickers when 'cmdheight' is zero. Solution: Redraw over existing text instead of clearing.
2022-08-28patch 9.0.0299: error messages for setcmdline() could be betterv9.0.0299Yegappan Lakshmanan
Problem: Error messages for setcmdline() could be better. Solution: Use more specific error messages. (Yegappan Lakshmanan, closes #10995)
2022-08-28patch 9.0.0293: messages window not hidden when starting a command linev9.0.0293Bram Moolenaar
Problem: Messages window not hidden when starting a command line. Solution: Hide the messages window. (closes #10996)
2022-08-27patch 9.0.0285: it is not easy to change the command line from a pluginv9.0.0285Shougo Matsushita
Problem: It is not easy to change the command line from a plugin. Solution: Add setcmdline(). (Shougo Matsushita, closes #10869)
2022-08-26patch 9.0.0279: the tiny version has the popup menu but not 'wildmenu'v9.0.0279Bram Moolenaar
Problem: The tiny version has the popup menu but not 'wildmenu'. Solution: Graduate the wildmenu feature.
2022-08-26patch 9.0.0271: using INIT() in non-header filesv9.0.0271zeertzjq
Problem: Using INIT() in non-header files. Solution: Remove INIT(). (closes #10981)
2022-08-21patch 9.0.0239: build failure without the +wildmenu featurev9.0.0239Bram Moolenaar
Problem: Build failure without the +wildmenu feature. Solution: Move parenthesis.
2022-08-21patch 9.0.0238: Shift-Tab shows matches on cmdline when 'wildmenu' is offv9.0.0238Bram Moolenaar
Problem: Shift-Tab shows matches on cmdline when 'wildmenu' is off. Solution: Only show matches when 'wildmode' contains "list". (closes #10951)