aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
Commit message (Collapse)AuthorAge
...
* refactor: move some functions to winfloat.c (#26020)Raphael2023-11-16
|
* vim-patch:8.1.1521: when a popup window is closed the buffer remains (#26024)zeertzjq2023-11-13
| | | | | | | | Problem: When a popup window is closed the buffer remains. Solution: Wipe out the buffer. https://github.com/vim/vim/commit/7c7f01e2b260c75d9996ca9ab621119eafe13a63 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* 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: change some xstrndup() and xstrnsave() to xmemdupz() (#25959)zeertzjq2023-11-10
| | | | When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer.
* 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.
* build(lint): remove unnecessary clint.py rulesdundargoc2023-10-23
| | | | | Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py.
* refactor(float): rename ex_floatclose to ex_fclose (#25596)Raphael2023-10-11
|
* Merge pull request #25561 from glepnir/9663bfredl2023-10-10
|\ | | | | feat(float): add fclose command
| * feat(float): add fclose commandglepnir2023-10-10
| |
* | fix(coverity): dead code #25562Justin M. Keyes2023-10-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *** CID 466056: Control flow issues (DEADCODE) /src/nvim/window.c: 6951 in file_name_in_line() 6945 // Search backward for first char of the file name. 6946 // Go one char back to ":" before "//", or to the drive letter before ":\" (even if ":" 6947 // is not in 'isfname'). 6948 while (ptr > line) { 6949 if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) { 6950 ptr -= len + 1; >>> CID 466056: Control flow issues (DEADCODE) >>> Execution cannot reach the expression "path_has_drive_letter(ptr - 2)" inside this statement: "if (vim_isfilec((uint8_t)pt...". 6951 } else if (vim_isfilec((uint8_t)ptr[-1]) 6952 || (len >= 2 && path_has_drive_letter(ptr - 2)) 6953 || ((options & FNAME_HYP) && path_is_url(ptr - 1))) { 6954 ptr--; 6955 } else { 6956 break;
* | 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.
* Merge pull request #25522 from glepnir/4334bfredl2023-10-07
|\ | | | | fix(ui): trigger TabNewEntered after split new tab
| * fix(ui): trigger TabNewEntered after split new tabglepnir2023-10-07
| |
* | fix: heap-buffer-overflow in file_name_in_lineJustin M. Keyes2023-10-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | heap-buffer-overflow on address 0x6020000079cf at pc 0x563e98bd70b6 bp 0x7ffc52efc430 sp 0x7ffc52efbbf8 = READ of size 1 at 0x6020000079cf thread T0 = 0 0x563e98bd70b5 in strlen (/home/runner/work/neovim/neovim/build/bin/nvim+0xc7b0b5) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2) = 1 0x563e99da4f45 in path_has_drive_letter /home/runner/work/neovim/neovim/src/nvim/path.c:1754:10 = 2 0x563e9a610d81 in file_name_in_line /home/runner/work/neovim/neovim/src/nvim/window.c:6951:49 = 3 0x563e9a61066f in file_name_at_cursor /home/runner/work/neovim/neovim/src/nvim/window.c:6917:10 = 4 0x563e995a08d6 in eval_vars /home/runner/work/neovim/neovim/src/nvim/ex_docmd.c:6903:16 = 5 0x563e9937c648 in f_expand /home/runner/work/neovim/neovim/src/nvim/eval/funcs.c:1754:20 = 6 0x563e99357819 in call_internal_func /home/runner/work/neovim/neovim/src/nvim/eval/funcs.c:273:3 = 7 0x563e994656de in call_func /home/runner/work/neovim/neovim/src/nvim/eval/userfunc.c:1719:15 = 8 0x563e99461ae6 in get_func_tv /home/runner/work/neovim/neovim/src/nvim/eval/userfunc.c:557:11 = 9 0x563e992c7c5d in eval_func /home/runner/work/neovim/neovim/src/nvim/eval.c:2281:13 = 10 0x563e992bf708 in eval7 /home/runner/work/neovim/neovim/src/nvim/eval.c:3208:15 = 11 0x563e992bbda9 in eval6 /home/runner/work/neovim/neovim/src/nvim/eval.c:2935:7 = 12 0x563e992b9e8d in eval5 /home/runner/work/neovim/neovim/src/nvim/eval.c:2791:7 = 13 0x563e992b87e2 in eval4 /home/runner/work/neovim/neovim/src/nvim/eval.c:2666:7 = 14 0x563e992b758d in eval3 /home/runner/work/neovim/neovim/src/nvim/eval.c:2575:7 = 15 0x563e9926299d in eval2 /home/runner/work/neovim/neovim/src/nvim/eval.c:2497:7 = 16 0x563e99250b0c in eval1 /home/runner/work/neovim/neovim/src/nvim/eval.c:2401:7 = 17 0x563e9924d68a in eval0 /home/runner/work/neovim/neovim/src/nvim/eval.c:2346:9 = 18 0x563e98f17315 in nvim_eval /home/runner/work/neovim/neovim/src/nvim/api/vimscript.c:170:3 = 19 0x563e98e7bb5e in handle_nvim_eval /home/runner/work/neovim/neovim/build/src/nvim/auto/api/private/dispatch_wrappers.generated.h:8953:15 = 20 0x563e99b62f59 in request_event /home/runner/work/neovim/neovim/src/nvim/msgpack_rpc/channel.c:444:19 = 21 0x563e9a1dcdc9 in state_handle_k_event /home/runner/work/neovim/neovim/src/nvim/state.c:115:7 = 22 0x563e99bf0718 in nv_event /home/runner/work/neovim/neovim/src/nvim/normal.c:6623:3 = 23 0x563e99bb4069 in normal_execute /home/runner/work/neovim/neovim/src/nvim/normal.c:1227:3 = 24 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26 = 25 0x563e99b9673c in normal_enter /home/runner/work/neovim/neovim/src/nvim/normal.c:516:3 = 26 0x563e98c82e0d in main /home/runner/work/neovim/neovim/src/nvim/main.c:643:3 = 27 0x7fcb81429d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd) = 28 0x7fcb81429e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd) = 29 0x563e98bc0f74 in _start (/home/runner/work/neovim/neovim/build/bin/nvim+0xc64f74) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2) = = 0x6020000079cf is located 1 bytes to the left of 9-byte region [0x6020000079d0,0x6020000079d9) = allocated by thread T0 here: = 0 0x563e98c43dbe in __interceptor_malloc (/home/runner/work/neovim/neovim/build/bin/nvim+0xce7dbe) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2) = 1 0x563e99a7b6f6 in try_malloc /home/runner/work/neovim/neovim/src/nvim/memory.c:89:15 = 2 0x563e99a7b8dc in xmalloc /home/runner/work/neovim/neovim/src/nvim/memory.c:123:15 = 3 0x563e9901ace2 in ins_str /home/runner/work/neovim/neovim/src/nvim/change.c:801:16 = 4 0x563e99208133 in insertchar /home/runner/work/neovim/neovim/src/nvim/edit.c:2172:5 = 5 0x563e9921936c in insert_special /home/runner/work/neovim/neovim/src/nvim/edit.c:1995:5 = 6 0x563e99218e9f in insert_handle_key /home/runner/work/neovim/neovim/src/nvim/edit.c:1173:7 = 7 0x563e991f0f1d in insert_execute /home/runner/work/neovim/neovim/src/nvim/edit.c:671:10 = 8 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26 = 9 0x563e991f8c75 in insert_enter /home/runner/work/neovim/neovim/src/nvim/edit.c:338:5 = 10 0x563e991ed4e2 in edit /home/runner/work/neovim/neovim/src/nvim/edit.c:1270:3 = 11 0x563e99bf6007 in invoke_edit /home/runner/work/neovim/neovim/src/nvim/normal.c:6269:7 = 12 0x563e99bcb665 in nv_edit /home/runner/work/neovim/neovim/src/nvim/normal.c:6246:5 = 13 0x563e99bb4069 in normal_execute /home/runner/work/neovim/neovim/src/nvim/normal.c:1227:3 = 14 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26 = 15 0x563e99b9673c in normal_enter /home/runner/work/neovim/neovim/src/nvim/normal.c:516:3 = 16 0x563e98c82e0d in main /home/runner/work/neovim/neovim/src/nvim/main.c:643:3 = 17 0x7fcb81429d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd)
* | fix: gf fails on "foo/bar.txt:1:2" on WindowsLeonardo Mello2023-10-06
|/ | | | | | | | | | | | | | | Problem: On Windows, "gf" fails on a filepath that has a line:column suffix. Example: E447: Can't find file "src/app/core/services/identity/identity.service.ts:64:23" Solution: - Remove ":" from 'isfname' on Windows. Colon is not a valid filename character (except for the drive-letter). - Handle drive letters specially in file_name_in_line(). Fixes #25160
* Merge pull request #25386 from glepnir/toggle_floatbfredl2023-09-30
|\ | | | | feat(float): support toggle show float window
| * feat(float): support toggle show float windowglepnir2023-09-30
| |
* | 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
* | build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
| |
* | refactor: remove longdundargoc2023-09-29
| | | | | | | | | | long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform.
* | refactor(messages): fold msg_attr into msgbfredl2023-09-27
|/ | | | | problem: there are too many different functions in message.c solution: fold some of the functions into themselves
* fix(float): make "fixed" work with relative=win (#25243)zeertzjq2023-09-19
|
* fix(float): add fixd optionglepnir2023-09-18
|
* fix(float): update position of anchored windows first (#25133)zeertzjq2023-09-14
|
* refactor(mch): last mch_ function/macro hits the dustbfredl2023-09-10
| | | | Also remove some stray comments.
* vim-patch:9.0.1877: missing test for patch 9.0.1873zeertzjq2023-09-09
| | | | | | | | | | | | Problem: missing test for patch 9.0.1873 Solution: add a test trying to exchange windows Add a test, making sure that switching windows is not allowed when textlock is active, e.g. when running `:s/<pat>/\=func()/` https://github.com/vim/vim/commit/18d2709aa12ffa3f6ae1a13059990558c5f8e406 Co-authored-by: Christian Brabandt <cb@256bit.org>
* feat(float): implement footerEvgeni Chasnovski2023-08-26
| | | | | | | | Problem: Now way to show text at the bottom part of floating window border (a.k.a. "footer"). Solution: Allows `footer` and `footer_pos` config fields similar to `title` and `title_pos`.
* refactor(change): do API changes to buffer without curbuf switchbfredl2023-08-26
| | | | | | | | | | | | | | | | | | | | | | | Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired.
* vim-patch:9.0.1710: scrolloff options work slightly differentzeertzjq2023-08-23
| | | | | | | | | | | | | | | | | | | | | | | Problem: sidescrolloff and scrolloff options work slightly different than other global-local options Solution: Make it behave consistent for all global-local options It was noticed, that sidescrolloff and scrolloff options behave differently in comparison to other global-local window options like 'listchars' So make those two behave like other global-local options. Also add some extra documentation for a few special local-window options. Add a few tests to make sure all global-local window options behave similar closes: vim/vim#12956 closes: vim/vim#12643 https://github.com/vim/vim/commit/4a8eb6e7a9df10f79bf95301ced012f0d6a13088 Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.0.1772: Cursor may be adjusted in 'splitkeep'ed windows (#24811)zeertzjq2023-08-21
| | | | | | | | | | | | Problem: Cursor is adjusted in window that did not change in size by 'splitkeep'. Solution: Only check that cursor position is valid in a window that has changed in size. closes: vim/vim#12509 https://github.com/vim/vim/commit/16af913eeefb288ce968fb87e09a597413861900 Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
* vim-patch:9.0.1726: incorrect heights in win_size_restore() (#24765)Sean Dewar2023-08-17
| | | | | | | | | Problem: incorrect heights in win_size_restore() Solution: avoid restoring incorrect heights in win_size_restore() https://github.com/vim/vim/commit/876f5fb570d8401aa4c58af4a5da91f10520aa9d I already merged this prior, so just replace the new test with the old one, but add a test case for the global statusline.
* refactor: cast to int earlier when using 'so' and 'siso' (#24756)zeertzjq2023-08-17
|
* fix(events): avoid unnecessary CursorMoved (#24675)zeertzjq2023-08-12
| | | | | | Problem: Temporarily changing current window in a script causes CursorMoved to be triggerd. Solution: Don't trigger CursorMoved if neither curwin nor cursor changed between two checks.
* fix(window): prevent win_size_restore from changing cmdheightSean Dewar2023-07-26
| | | | | | | | | | | | | | | | | | | | | Currently it only skips if `Rows` changed, but it's possible for the height of the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which can cause the value of `&cmdheight` to change when the sizes are restored. This is a Vim bug, so I've submitted a PR there too. No telling when it'll be merged though, given the current lack of activity there. `ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`. Not ideal, as we also care about the height of the last statusline for other values of `&ls`. Meh. Introduce `last_stl_height` for getting the height of the last statusline and use it in `win_size_save/restore` and `last_status` (means `last_status_rec`'s `statusline` argument will now be true if `&ls` is 3, but that does not change the behaviour). Also corrects the logic in `comp_col` to not assume there's a last statusline if `&ls` is 1 and the last window is floating.
* feat(api): allow win_hide to close cmdwin or non-previous windowsSean Dewar2023-07-26
| | | | | | | This aligns its behaviour better with `nvim_win_close`. Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close` and `:quit`, so this is a bit of a difference in behaviour.
* feat(api): allow open_win/win_set_buf in the cmdwin in some casesSean Dewar2023-07-26
| | | | | | | | | | | | | | | | | | | | | | Problem: As discussed on Matrix, there was some interest in having `nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a hover doc related to what's in the cmdwin). After #23228, this was disallowed. Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and `buffer != curbuf` (the former can cause all sorts of issues, and the latter can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar fashion. Note that we're not *entirely* sure if this is 100% safe (cmdwin is a global-state-using-main-loop-calling beast), but this seems to work OK..? Also: - Check the buffer argument of `nvim_open_win` earlier, and abort if it's invalid (it used to still open a window in this case). - Untranslate `e_cmdwin` errors in the API (other errors in the API are not translated: although not detailed in the API contract yet, errors are supposed to be stable).
* feat(api)!: change return type of nvim_win_text_height to Dict (#24365)zeertzjq2023-07-16
|
* refactor(plines.c): update outdated comments (#24264)zeertzjq2023-07-06
|
* fix(ui): delay win_viewport until screen update #24182fredizzimo2023-07-05
| | | | | | | | | | | | | | | | | | | | | | | | Problem: Sometimes, when nvim sends the `win_viewport` event, for example when scrolling with visible folds on the screen, it reports the `scroll_delta` value one batch into "future". So when the client application is trying to show the new viewport it's not yet updated, resulting in temporary corruption / screen flickering. For more details see #23609, and starting from [this comment]( https://github.com/neovide/neovide/pull/1790#issuecomment-1518697747) in https://github.com/neovide/neovide/pull/1790,, where the issue was first detected. Note that some of the conclusions in those are not fully accurate, but the general observations are. Solution: When there are pending updates to a Window, delay the `win_viewport` UI event until the updates are sent. This ensures that there's no flush between sending the viewport and updating of the lines corresponding to the new viewport. Document the existing viewport behaviour (for cases where there are no extra flushes), give a hint about how applications can deal with the slightly surprising behaviour of the viewport event being sent after the updates. Fixes https://github.com/neovim/neovim/issues/23609
* perf(ui-ext): approximate scroll_delta when scrolling too much (#24234)zeertzjq2023-07-04
|
* fix(ui-ext): "scroll_delta" handle topfill and skipcol (#24249)zeertzjq2023-07-04
|
* refactor: remove longdundargoc2023-07-03
| | | | | long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform.
* vim-patch:9.0.1608: update_topline() is called twice (#23920)luukvbaal2023-06-05
| | | | | | | Problem: update_topline() is called twice. Solution: Do not call update_topline() before curs_columns(). (Luuk van Baal, closes vim/vim#12495) https://github.com/vim/vim/commit/5c606846b9a43c7e6b94c7e96838f7532792f557
* fix(events)!: trigger CursorMoved later on switching window (#23711)zeertzjq2023-06-04
|
* vim-patch:9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor" ↵luukvbaal2023-06-02
| | | | | | | | | | | (#23884) Problem: Cursor not adjusted when near top or bottom of window and 'splitkeep' is not "cursor". Solution: Move boundary checks to outer cursor move functions, inner functions should only return valid cursor positions. (Luuk van Baal, closes vim/vim#12480) https://github.com/vim/vim/commit/a109f39ef54bc3894768170f02c1b6ac56164488
* refactor(map): avoid duplicated khash_t types for valuesbfredl2023-05-17
| | | | | | | | | | | | | | | | | | | | | This reduces the total number of khash_t instantiations from 22 to 8. Make the khash internal functions take the size of values as a runtime parameter. This is abstracted with typesafe Map containers which are still specialized for both key, value type. Introduce `Set(key)` type for when there is no value. Refactor shada.c to use Map/Set instead of khash directly. This requires `map_ref` operation to be more flexible. Return pointers to both key and value, plus an indicator for new_item. As a bonus, `map_key` is now redundant. Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is humongous. Make `event_strings` actually work like an intern pool instead of wtf it was doing before.
* vim-patch:9.0.1554: code for handling 'switchbuf' is repeated (#23632)zeertzjq2023-05-15
| | | | | | | | | Problem: Code for handling 'switchbuf' is repeated. Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan, closes vim/vim#12397) https://github.com/vim/vim/commit/e42c27d9e8a18e3786f13f17663914cdd0f63f9e Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.0598: using negative array index with negative width windowzeertzjq2023-05-13
| | | | | | | | | Problem: Using negative array index with negative width window. Solution: Make sure the window width does not become negative. https://github.com/vim/vim/commit/8279af514ca7e5fd3c31cf13b0864163d1a0bfeb Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.1546: some commands for opening a file don't use 'switchbuf' ↵zeertzjq2023-05-13
| | | | | | | | | | | (#23600) Problem: Some commands for opening a file don't use 'switchbuf'. Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan, closes vim/vim#12383, closes vim/vim#12381) https://github.com/vim/vim/commit/54be5fb382d2bf25fd1b17ddab8b21f599019b81 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>