Commit Graph

17724 Commits

Author SHA1 Message Date
zeertzjq ee89ba1d75
vim-patch:9.1.0182: Can define function with invalid name inside 'formatexpr' (#27883)
Problem:  Can define function with invalid name inside 'formatexpr'.
Solution: Use goto instead of checking for did_emsg later.
          (zeertzjq)

closes: vim/vim#14209

6a04bf5ee5
2024-03-16 17:26:14 +08:00
zeertzjq c0daea3afd
vim-patch:9.1.0183: Wrong display or screenpos() result when toggling diff mode (#27882)
Problem:  Wrong display or screenpos() result when toggling diff mode.
Solution: Reset w_skipcol when disabling 'wrap'.  Reset w_leftcol when
          enabling 'wrap' (zeertzjq).

fixes: vim/vim#14210
closes: vim/vim#14211

9e7f1fc2f1
2024-03-16 17:10:20 +08:00
zeertzjq ead3a1bd7a
vim-patch:8.2.3782: Vim9: no error if a function shadows a script variable (#27881)
Problem:    Vim9: no error if a function shadows a script variable.
Solution:   Check the function doesn't shadow a variable. (closes vim/vim#9310)

052ff291d7

Omit EVAL_VAR_NO_FUNC: Vim9 script only.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-03-16 17:05:59 +08:00
bfredl 9c2fdfe6e7
Merge pull request #27877 from bfredl/pseudorandom
fix(intro): redrawing intro exposing pseudo-randomness
2024-03-16 09:32:52 +01:00
bfredl d1a30221fc fix(intro): redrawing intro exposing pseudo-randomness
problem:  redrawing intro exposes pseudo-randomness
solution: remove pseudo-randomness
2024-03-16 08:40:45 +01:00
bfredl c0549b9c47
Merge pull request #27871 from bfredl/ui_flush_fix
fix(ui): edge case around flushing in grid_line
2024-03-16 08:36:37 +01:00
ite-usagi 4447cefa48
fix(l10n): update Japanese translations (#27856) 2024-03-16 14:50:52 +08:00
bfredl b7779c5146
Merge pull request #27867 from bfredl/intro_multigrid
fix(ui): startup intro message should be visible with ext_multigrid
2024-03-15 13:27:58 +01:00
bfredl e0707d3529 fix(ui): fix edge case around flushing
ui_flush_buf() doesn't know about `lenpos` so `remote_ui_raw_line`
needs to always handle it before flushing
2024-03-15 12:07:04 +01:00
bfredl f1c9228bba
Merge pull request #27858 from luukvbaal/nvim_set_cursor
fix(ui): issues controlling cursor position with ext_cmdline
2024-03-15 10:02:26 +01:00
bfredl a8522f02e9 fix(ui): startup intro message should be visible with ext_multigrid
As this message is literally drawn on top of the EOB area of the first
window, the simple solution is to just draw the message on top of the
grid of the first window.

We still want #24764 (msg_intro event) but now only for ext_messages.
2024-03-15 09:48:31 +01:00
Luuk van Baal d41b8d4758 fix(ui): ext_cmdline should not move cursor to curwin
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).
2024-03-15 09:15:56 +01:00
Luuk van Baal c971f538ab fix(api): update grid cursor in nvim_win_set_cursor()
Problem:  Cursor position set by nvim_win_set_cursor() is not reflected
          on the screen when followed by a blocking call like getchar().
Solution: Immediately update the cursor position on the grid.
2024-03-15 09:15:50 +01:00
zeertzjq 062c0245e3
refactor: remove unused "coloff" argument of win_put_linebuf() (#27866)
It isn't really used, and is always passed 0.
Also rename "start_col" to "startcol" for consistency with "endcol".
2024-03-15 14:45:58 +08:00
zeertzjq d326e04860
vim-patch:9.1.0181: no overflow check for string formatting (#27863)
Problem:  no overflow check for string formatting
Solution: Check message formatting function for overflow.
          (Chris van Willegen)

closes: vim/vim#13799

c35fc03dbd

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2024-03-15 08:05:59 +08:00
zeertzjq 60491466f9
vim-patch:9.1.0180: Cursor pos wrong when double-width chars are concealed (#27862)
Problem:  Cursor pos wrong when double-width chars are concealed.
Solution: Advance one more virtual column for a double-width char.
          Run some tests with both 'wrap' and 'nowrap' (zeertzjq).

closes: vim/vim#14197

010e1539d6
2024-03-15 06:56:45 +08:00
zeertzjq ca7dd33fa7
fix(highlight): don't show CursorColumn on current line (#27848)
Problem:
CursorColumn highlight behavior is inconsistent with 'virtualedit' set:
- If cursor is on the text, CursorColumn is not shown.
- If cursor is after end of line, CursorColumn is shown.

Solution:
Don't shown CursorColumn on current line if cursor is after end of line.

Vim doesn't have this problem because in most cases it uses the code
path for drawing buffer text when CursorColumn highlight is needed.
2024-03-15 05:54:22 +08:00
bfredl 4de4f13eb3
Merge pull request #27852 from bfredl/persistent_intro
fix(intro): make intro explicitly stateful
2024-03-14 20:00:07 +01:00
bfredl 0570a19c8a fix(intro): make intro explicitly stateful
Instead of randomly disappearing because some random event might have
caused mid_start or bot_scroll_start to randomly take a low value, treat
intro message as a _first class stateful_ thing.

This means that intro message will kept being _redrawn_ as long as we
are in the state it should be shown. This also includes screen resizes.
you will not lose the intro message because there was a delay in
detecting terminal features.
2024-03-14 14:39:08 +01:00
zeertzjq a6b6d036b1
refactor(drawline): rename vcol_off to vcol_off_co (#27857)
It is clearing that it's for conceal and matches the change from Vim
patch 9.0.1325.
Also correct some comments related to fix_for_boguscols().
2024-03-14 19:33:14 +08:00
bfredl cdd0788c70
Merge pull request #27854 from bfredl/boogalo_lines
fix(api): fix set_lines viewport adjustment, but this time good
2024-03-14 12:24:33 +01:00
Christian Clason 120c4ec855 fix(terminal): disable reflow again
reverts c855eee919

This setting introduces constant CI failures on macos
(see https://github.com/neovim/neovim/issues/23762).
2024-03-14 19:22:16 +08:00
bfredl fc2a56fe61 fix(api): fix set_lines viewport adjustment, but this time good
fixes #27720
2024-03-14 10:56:24 +01:00
zeertzjq 61b48e91b9 vim-patch:9.1.0177: Coverity reports dead code
Problem:  Coverity reports dead code.
Solution: Remove the dead code. Also fix a mistake in ml_get_pos_len()
          and update some comments (zeertzjq).

closes: vim/vim#14189

8c55d60658
2024-03-14 13:09:57 +08:00
zeertzjq 090d1fd0b8 vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
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

94b7c3233e
2024-03-14 13:09:54 +08:00
zeertzjq 3502aa63f0
vim-patch:8.2.4950: text properties position wrong after shifting text (#27849)
Problem:    Text properties position wrong after shifting text.
Solution:   Adjust the text properties when shifting a block of text.
            (closes vim/vim#10418)

4b93674159

Most of the patch is already merged. Add an assertion in place of "added".

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2024-03-14 12:40:17 +08:00
zeertzjq 2af1dc0116 vim-patch:9.1.0176: Cursor column wrong with 'virtualedit' and conceal
Problem:  Cursor column wrong with 'virtualedit' and conceal.
Solution: Correct cursor column at end of line if never reached.
          (zeertzjq)

closes: vim/vim#14190

253ff4dece
2024-03-14 06:55:10 +08:00
zeertzjq 9599e5d28d vim-patch:9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap
Problem:  'cursorline' and 'wincolor' highlight missing with concealed and
          wrapped lines.
Solution: Apply 'cursorline' and 'wincolor' highlight to boguscols.
          (zeertzjq)

Since 'cursorline' and 'wincolor' highlight apply after the end of the
line, it is more consistent to have them also apply to boguscols.

Assigning MAXCOL to values in ScreenCols[] make mouse click behave the
same with 'cursorline' and 'nocursorline', but such behavior may be
incorrect, as it puts the cursor on the next screen line.  That may be
fixed in a future PR.

closes: vim/vim#14192

21b0a3df8c
2024-03-14 06:55:08 +08:00
zeertzjq b17be231a6
vim-patch:9.1.0178: E1513 might be confusing (#27846)
Problem:  E1513 might be confusing
          (Christoph Thoma)
Solution: reword error message, fix test to not
          depend on the actual message

fixes: vim/vim#14189

0a32b8854b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-03-14 06:44:50 +08:00
Sean Dewar bbb68e2a03
vim-patch:9.1.0175: wrong window positions with 'winfix{width,height}' (#27845)
Problem:  winframe functions incorrectly recompute window positions if
          the altframe wasn't adjacent to the closed frame, which is
          possible if adjacent windows had 'winfix{width,height}' set.

Solution: recompute for windows within the parent of the altframe and
          closed frame. Skip this (as before) if the altframe was
          top/left, but only if adjacent to the closed frame, as
          positions won't change in that case. Also correct the return
          value documentation for win_screenpos. (Sean Dewar)

The issue revealed itself after removing the win_comp_pos call below
winframe_restore in win_splitmove. Similarly, wrong positions could result from
windows closed in other tabpages, as win_free_mem uses winframe_remove (at least
until it is entered later, where enter_tabpage calls win_comp_pos).

NOTE: As win_comp_pos handles only curtab, it's possible via other means for
positions in non-current tabpages to be wrong (e.g: after changing 'laststatus',
'showtabline', etc.). Given enter_tabpage recomputes it, maybe it's intentional
as an optimization? Should probably be documented in win_screenpos then, but I
won't address that here.

closes: vim/vim#14191

Nvim: don't reuse "wp" for "topleft" in winframe_remove, so the change
integrates better with the call to winframe_find_altwin before it.

5866bc3a0f
2024-03-13 22:06:39 +00:00
bfredl 08fc1ebbaa fix(api/buffer): fix handling of viewport of non-current buffer
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
2024-03-13 07:19:59 +01:00
zeertzjq d5488633f6
fix(drawline): initialize linebuf_attr to 0 instead of -1 (#27840)
This also obviates the end-of-line loop when there is virtual text.
2024-03-13 11:36:41 +08:00
zeertzjq 93c93a0e36
refactor: remove "once" argument of loop_uv_run() (#27841)
It is always set to true when used, and makes the code a bit confusing.
2024-03-13 11:27:04 +08:00
Sean Dewar c048beef6c
vim-patch:9a660d2883f9
runtime(doc): add reference to matchbufline() at :h search()

related: vim/vim#14173

9a660d2883

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-03-12 21:42:47 +00:00
Sean Dewar 6bbb02d9ba
vim-patch:9.1.0171: Small split-move related improvements
Problem:  small improvements can be made to split-move related
          functions.
Solution: apply them (Sean Dewar):

Some of these changes were already applied to Nvim.
Here are the ones which were missing:

- Improve some doc comments (frame_flatten should still work for non-current
  tabpages, despite the topframe check, which looks benign, though I'm unsure if
  it's still needed; see vim/vim#2467).

- f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's
  what win_splitmove checks (though it's probably unnecessary to check
  b_locked_split at all; see vim/vim#14109, which I hope to get around to
  finishing at some point).

- Apply the winframe_restore comment changes, and remove win_comp_pos from after
  winframe_restore in win_splitmove, as it shouldn't be necessary (no need to
  remove it from nvim_win_set_config too, as it was already omitted).
  Move win_append after winframe_restore in win_splitmove to match Vim.

closes: vim/vim#14185

5cac1a9bee
2024-03-12 21:38:39 +00:00
Sean Dewar ca7b603d02
vim-patch:9.1.0170: Re-allow curwin == prevwin, but document it instead
Problem:  more places exist where curwin == prevwin, and it may even be
          expected in some cases.
Solution: revert v9.1.0001, but document that it's possible instead.
          (Sean Dewar)

I've had a change of heart for the following reasons:

- A quick 'n dirty [GitHub code search](https://github.com/search?q=%2F%28winnr%5C%28%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%7Cwinnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5C%29%29%2F&type=code)
  reveals some cases where it's expected in the wild.

  Particularly, it made me aware `winnr() == winnr('#')` is possible when curwin
  is changed temporarily during the evaluation of a &statusline expression item
  (`%{...}`), and is used to show something different on the statusline
  belonging to the previous window; that behaviour wasn't changed in v9.1.0001,
  but it means curwin == prevwin makes sense in some cases.

- The definition and call sites of back_to_prevwin imply some expectation that
  prevwin == wp (== curwin) is possible, as it's used to skip entering the
  prevwin in that case.

- Prior to v9.1.0001, `:wincmd p` would not beep in the case that was patched in
  v9.1.0001, but now does. That resulted in vim/vim#14047 being opened, as it affected
  the CtrlP plugin.

  I find it odd that `:wincmd p` had cases where it wouldn't beep despite doing
  nothing, but it may be preferable to keep things that way (or instead also
  beep if curwin == prevwin, if that's preferred).

- After more digging, I found cases in win_free_mem, enter_tabpage,
  aucmd_restbuf and qf_open_new_cwindow where curwin == prevwin is possible
  (many of them from autocommands). Others probably exist too, especially in
  places where curwin is changed temporarily.

fixes: vim/vim#14047
closes: vim/vim#14186

d64801e913
2024-03-12 21:14:40 +00:00
Sean Dewar 29d0ed577c
vim-patch:9.1.0169: current window number returned by tabpagewinnr may be outdated
Problem:  current window number returned by tabpagewinnr may be outdated
          when called from win_execute for the original tabpage.
Solution: update the original tabpage's tp_curwin in switch_win; use
          {un}use_tabpage instead. Don't do it in restore_win to ensure
          tp_curwin of the temporarily visited tabpage is unchanged from
          switch_win visiting it, as before. (Sean Dewar)

Maybe restore_win should only restore tp_curwin if
`curtab == switchwin->sw_curtab`, in case the user changed tabpages from within
win_execute, but not doing that is consistent with the old behaviour.

related: vim/vim#14186

e101028a5c
2024-03-12 21:05:54 +00:00
James 119390e7ce
refactor: avoid copying before vim_strup() if possible (#27830)
Current uses of vim_strup() calls memcpy()/strcpy() before calling vim_strup().
This results in 2 * strlen(string) operations.

We can trivially convert to lowercase while copying the string instead.
2024-03-13 04:34:59 +08:00
James McCoy dd0fc73bbe
Merge pull request #27808 from jamessan/gen_cflags-cleanup
Cleanup construction of command-lines for header generation
2024-03-12 14:00:29 -04:00
James 3bd84317fb
refactor: avoid quadratic behavior in backslash_halve() (#27827)
The original implementation has a worst-case of O(n^2). Every time
rem_backslash() is true, it calculates the length of the rest of the
string, and shift the rest of it to the left; backslash_halve_save()
copies the original string before doing backslash_halve().

The new implementation is O(n). It will find the first character where
rem_backslash() is true (it will do nothing if it's always false), and
shift the characters in-place; backslash_halve_save() avoids copying the
original string before doing backslash_halve().
2024-03-12 14:35:53 +08:00
dundargoc a74e869ffa
docs: small fixes (#27364)
Co-authored-by: C.D. MacEachern <craig.daniel.maceachern@gmail.com>
Co-authored-by: Ynda Jas <yndajas@gmail.com>
Co-authored-by: Owen Hines <TheOdd@users.noreply.github.com>
Co-authored-by: Wanten <41904684+WantenMN@users.noreply.github.com>
Co-authored-by: lukasvrenner <118417051+lukasvrenner@users.noreply.github.com>
Co-authored-by: cuinix <915115094@qq.com>
2024-03-12 13:51:53 +08:00
zeertzjq ac8cd5368d
refactor: use ml_get_buf_len() in API code (#27825) 2024-03-12 10:44:53 +08:00
zeertzjq b02a4d8ac3
vim-patch:9.1.0168: too many STRLEN() calls (#27823)
Problem:  too many STRLEN() calls
Solution: Make use of ml_get_len() calls instead
          (John Marriott)

closes: vim/vim#14123

bfcc895482

Co-authored-by: John Marriott <basilisk@internode.on.net>
2024-03-12 07:20:22 +08:00
zeertzjq 6481da3015
vim-patch:9.1.0166: Internal error with blockwise getregion() in another buffer (#27819)
Problem:  Internal error with blockwise getregion() in another buffer
Solution: Also change curwin->w_buffer when changing curbuf (zeertzjq)

closes: vim/vim#14179

5406eb8722
2024-03-12 07:19:30 +08:00
zeertzjq cf156377e8
vim-patch:8.2.4944: text properties are wrong after "cc" (#27821)
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)

d0b1a09f44

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2024-03-12 06:56:06 +08:00
zeertzjq 9cc755ad6a
vim-patch:0049a495c8d4 (#27817)
runtime(doc): improve 'winfixbuf' docs (vim/vim#14180)

- Make it not sound like a buffer option.
- "!" is called a modifier, not an option.

0049a495c8
2024-03-12 05:39:21 +08:00
Luuk van Baal b72931e704 feat(ui): allow non-zero 'cmdheight' with ext_messages
Problem:  Arbitrary restriction on 'cmdheight' with ext_messages.
          The 'cmdheight'-area may be desirable for the replacing
          cmdline.
Solution: Allow non-zero 'cmdheight' with ext_messages.
2024-03-11 07:13:48 +01:00
zeertzjq 3b3511c4d9 vim-patch:9.1.0156: Make 'wfb' failing to split still report E1513
Problem:  may not be clear why failing to split causes an ":Xdo" command
          to abort if 'wfb' is set.
Solution: do not return immediately if win_split fails, so E1513 is
          still given. Expect both errors in the test. Also fix tests to
          pass CI.
          (Sean Dewar)

closes: vim/vim#14152

769eb2d0c3

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2024-03-11 11:42:03 +08:00
zeertzjq d71791a11a vim-patch:9.1.0152: Coverity complains about ignoring return value
Problem:  Coverity complains about ignoring return value of win_split()
          (after v9.1.150)
Solution: Check if win_split() failed, add winfixbuf.res to Makefile

af7ae81600

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-03-11 11:38:15 +08:00
Colin Kennedy 5931f2bc4a vim-patch:9.1.0150: Several minor 'winfixbuf' issues
Problem:  several minor 'winfixbuf' issues exist, mostly relating to the
          quickfix list
Solution: address them and adjust tests. Retab and reflow a few things too.
          (Sean Dewar)

Things touched include:

- Replace the semsgs with gettext'd emsgs.

- Handle window switching in ex_listdo properly, so curbuf and curwin
  are kept in-sync and trigger autocommands; handle those properly.

- Don't change the list entry index in qf_jump_edit_buffer if we fail
  due to 'wfb' (achieved by returning FAIL; QF_ABORT should only be used
  if the list was changed).

- Make qf_jump_edit_buffer actually switch to prevwin when using `:cXX`
  commands **outside** of the list window if 'wfb' is set in curwin.
  Handle autocommands properly in case they mess with the list.

  NOTE: previously, it seemed to split if 'wfb' was set, but do nothing
  and fail if prevwin is *valid*. This behaviour seemed strange, and maybe
  unintentional? Now it aligns more with what's described for the `:cXX`
  commands in the original PR description when used outside a list window,
  I think.

- In both functions, only consider prevwin if 'wfb' isn't set for it;
  fallback to splitting otherwise.

- Use win_split to split. Not sure if there was a specific reason for
  using ex_splitview. win_split is simpler and respects modifiers like
  :vertical that may have been used. Plus, its return value can be checked
  for setting opened_window in qf code (technically win_split_ins autocmds
  could immediately close it or change windows, in which the qf code might
  close some other window on failure; it's already the case elsewhere,
  though).

closes: vim/vim#14142

4bb505e28c

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2024-03-11 11:38:15 +08:00
Colin Kennedy e8bc23db62 vim-patch:9.1.0149: null pointer member access when accessing 'winfixbuf' property
Problem:  qf_goto_win_with_qfl_file may check if prevwin has 'winfixbuf'
          set without checking if it's valid first.
Solution: Reverse the condition. Add a test, a modeline, and a missing
          CheckFeature. (Searn Dewar)

closes: vim/vim#14140

5131f224da

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2024-03-11 11:38:15 +08:00
Colin Kennedy 141182d6c6 vim-patch:9.1.0147: Cannot keep a buffer focused in a window
Problem:  Cannot keep a buffer focused in a window
          (Amit Levy)
Solution: Add the 'winfixbuf' window-local option
          (Colin Kennedy)

fixes:  vim/vim#6445
closes: vim/vim#13903

2157035637

N/A patch:
vim-patch:58f1e5c0893a
2024-03-11 11:38:13 +08:00
James McCoy 118fd8367c
fix: deduplicate gen_cflags
Since many of the targets have common include paths, `gen_cflags`
accumulates a lot of duplicate flags.
2024-03-10 20:02:32 -04:00
James McCoy 74b2f6c3d9
fix: ignore non-existent properties during header generation
`get_target_property(<var> ...)` sets `<var>` to `<var>-NOTFOUND` if the
property doesn't exist for the given target.  Detect this situation to
avoid adding various `-Dprop-NOTFOUND` and `-Iprop-NOTFOUND` to the
command-line when generating the headers.
2024-03-10 19:58:35 -04:00
zeertzjq 92d4dbbd8c
vim-patch:9.1.0164: Internal error when passing invalid position to getregion() (#27805)
Problem:  Internal error or crash when passing invalid position to
          getregion().
Solution: Give an error for invalid position (zeertzjq).

closes: vim/vim#14172

26dd09ad5e
2024-03-11 06:21:32 +08:00
zeertzjq b465ede2c7
vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799)
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

02d7a6c6cf

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>
2024-03-10 17:08:00 +08:00
zeertzjq a441bdc936
vim-patch:9.1.0162: problem with writing extended attributes on failure (#27800)
Problem:  problem with writing extended attributes on failure
Solution: Change return type to ssize_t and check listxattr's return
          value correctly on failure (Paul Tagliamonte)

The existing logic will return when the listxattr call returns with the
errno set to ENOTSUP (or a size of 0 bytes), without checking to see if
listxattr actually failed. listxattr can fail with at least E2BIG,
ENOTSUP, ERANGE, or anything that `stat(2)` can fail with (in my case;
ENOENT from stat).

The returned size is stored to a size_t, but the return type is a
ssize_t. On failure, listxattr returns -1, which will get translated to
size_t's MAX. If the listxattr call failed with anything other than
ENOTSUP, this triggers a request for size_t MAX bytes.

This means that, if the listxattr call fails with anything other than
ENOTSUP on save, vim will error with

`E342: Out of memory!  (allocating 18446744073709551615 bytes)`

(keen observers will note 18446744073709551615 is 0xffffffffffffffff)

In reality, this is likely masking a different (usually filesystem?)
error -- but at least it's an error being pushed to the user now, and we
don't try to allocate size_t MAX bytes.

I've opted to change the type that we store listxattr to from size_t to
ssize_t, to match listxattr(2)'s signature, and to check for the -1
return value. Additionally, I've removed the errno check -- if we get a
listxattr failure for any reason, we may as well bail without trying;
it's not like we can even recover.

closes: vim/vim#14169

14759ded57

Co-authored-by: Paul R. Tagliamonte <paultag@gmail.com>
2024-03-10 16:58:01 +08:00
zeertzjq 6052b346f1
revert: "fix(window): :close crash with autocmd, floats and tabpage" (#27796)
This reverts PR #27793.

On second thought, this solution may still crash, because it can leave a
window with a NULL buffer if there are autocommand windows or if closing
a floating window fails. It also makes close_last_window_tabpage() more
complicated, so revert it.
2024-03-10 10:33:10 +08:00
zeertzjq 9bd4a28079
fix(window): :close crash if WinClosed from float closes window (#27794)
Problem:  :close crash if WinClosed from float closes window.
Solution: Check if window has already been closed.
2024-03-10 08:37:16 +08:00
zeertzjq 731e7f51ee
fix(window): :close crash with autocmd, floats and tabpage (#27793)
Problem:  :close crash with autocmd, floats and tabpage.
Solution: Close floating windows in one more case.
2024-03-10 07:55:04 +08:00
zeertzjq 448cf10c47
vim-patch:9.1.0159: Crash in WinClosed after BufUnload closes other windows (#27792)
Problem:  Crash in WinClosed after BufUnload closes other windows
Solution: Don't trigger WinClosed if the buffer is NULL (zeertzjq)

Now win_close_othertab() doesn't trigger any autocommands if the buffer
is NULL, so remove the autocmd blocking above (which was added not long
ago in patch v9.0.0550) for consistency.

Also remove an unreachable close_last_window_tabpage() above:
- It is only reached if only_one_window() returns TRUE and last_window()
  returns FALSE.
- If only_one_window() returns TRUE, there is only one tabpage.
- If there is only one tabpage and last_window() returns FALSE, the
  one_window() in last_window() must return FALSE, and the ONE_WINDOW
  in close_last_window_tabpage() must also be FALSE.
- So close_last_window_tabpage() doesn't do anything and returns FALSE.

Then the curtab != prev_curtab check also doesn't make much sense, and
the only_one_window() can be replaced with a check for popup and a call
to last_window() since this is a stricter check than only_one_window().

closes: vim/vim#14166

b2ec0da080
2024-03-10 07:03:36 +08:00
zeertzjq 241c161299
vim-patch:9.1.0161: expand() removes slash after env variable that ends with colon (#27791)
Problem:  expand() removes a slash after an environment variable that
          ends with a colon on Windows.
Solution: Check the correct char for a colon (zeertzjq)

closes: vim/vim#14161

Note: Vim still removes the path-separator at the end, if another path separator
follows directly after it, e.g. on:

```
    echo $FOO='/usr/'
    echo expand('$FOO/bar') == '/usr/bar'
```

see:

,----[ misc1.c:1630 ]
|   // if var[] ends in a path separator and tail[] starts
|   // with it, skip a character
|   if (after_pathsep(dst, dst + c)
| #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA)
| 	  && (dst == save_dst || dst[-1] != ':')
| #endif
| 	  && vim_ispathsep(*tail))
|       ++tail;
`----

13a014452a

Cherry-pick test_expand.vim change from patch 9.0.1257.
2024-03-10 06:47:09 +08:00
Sean Dewar b596732831
Merge pull request #27330 from seandewar/win_set_config-fixes
fix(api): various window-related function fixes

This is a big one!
2024-03-09 22:32:20 +00:00
Sean Dewar c3d22d32ee
vim-patch:8.2.3862: crash on exit with EXITFREE and using win_execute()
Problem:    Crash on exit with EXITFREE and using win_execute().
Solution:   Also save and restore tp_topframe. (issue vim/vim#9374)

dab17a0689

Couldn't repro the crash in the test, but I only care about this patch so
switch_win sets topframe properly for win_split_ins in nvim_open_win and
nvim_win_set_config.
Add a test using nvim_win_call and :wincmd, as I couldn't repro the issue via
nvim_open_win or nvim_win_set_config (though it's clear they're affected by this
patch).

That said, at that point, could just use {un}use_tabpage inside switch_win
instead, which also updates tp_curwin (though maybe continue to not set it in
restore_win). That would also fix possible inconsistent behaviour such as:

:call win_execute(w, "let curwin_nr1 = tabpagewinnr(1)")
:let curwin_nr2 = tabpagewinnr(1)

Where it's possible for curwin_nr1 != curwin_nr2 if these commands are run from
the 1st tabpage, but window "w" is in the 2nd (as the 1st tabpage's tp_curwin
may still be invalid). I'll probably PR a fix for that later in Vim.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-03-09 21:58:30 +00:00
Sean Dewar b52d15853e
fix(api): win_set_config set tp_curwin of win moved from other tabpage
Problem: nvim_win_set_config does not update the tp_curwin of win's original
tabpage when moving it to another.

Solution: update it if win was the tp_curwin. Add a test.
2024-03-09 18:00:30 +00:00
Lewis Russell ade1b12f49 docs: support inline markdown
- Tags are now created with `[tag]()`
- References are now created with `[tag]`
- Code spans are no longer wrapped
2024-03-09 11:21:55 +00:00
Raphael 0e28493914
vim-patch:8.2.3915: illegal memory access when completing with invalid bytes (#27491)
Problem:    illegal memory access when completing with invalid bytes.
Solution:   Avoid going over the end of the completion text.

vim/vim@4b28ba3

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-03-09 19:21:31 +08:00
glepnir b21d960119 fix(startup): set full_screen when in ex_mode
Problem Description: In ex_mode, the default_grid.chars are not allocated, and subsequently,
the w_grid.target in curwin is not allocated to default_grid in update_screen. This leads to
a null pointer crash when the completion function is executed in ex_mode.

Solution: Set full_screen when in ex_mode to ensure that default_grid is allocated.
2024-03-09 18:20:59 +08:00
zeertzjq 33dfb5a383 fix(window): :close may cause Nvim to quit with autocmd and float
Problem:  :close may cause Nvim to quit if an autocommand triggered when
          closing the buffer closes all other non-floating windows and
          there are floating windows.
Solution: Correct the check for the only non-floating window.
2024-03-09 13:38:32 +08:00
Sean Dewar 54022a2946
fix(api): win_set_config update statuslines after removing splits
Problem: nvim_win_set_config does not update statuslines after removing a split.

Solution: call last_status.

Didn't realize this was missing in the original nvim_win_set_config for splits
PR.

As it can only be done for the current tabpage, do it if win_tp == curtab;
enter_tabpage will eventually call last_status anyway when the user enters
another tabpage.
2024-03-09 01:00:33 +00:00
Sean Dewar e7c262f555
fix(api): patch some cmdwin/textlock holes
Problem: there are new ways to escape textlock or break the cmdwin in
nvim_win_set_config and nvim_tabpage_set_win.

Solution: fix them. Use win_goto to check it in nvim_tabpage_set_win and use the
try_start/end pattern like with similar functions such as nvim_set_current_win
(which uses the existing msg_list, if set).

Careful not to use `wp->handle` when printing the window ID in the error message
for nvim_tabpage_set_win, as win_goto autocommands may have freed the window.

On a related note, I have a feeling some API functions ought to be checking
curbuf_locked...
2024-03-08 23:24:06 +00:00
Sean Dewar d942c2b943
fix(api): handle win_split_ins failure properly
Problem: nvim_win_set_config does not handle failure in win_split_ins properly
yet, which can cause all sorts of issues. Also nvim_open_win and
nvim_win_set_config do not set the error message to the one from win_split_ins.

Solution: handle failure by undoing winframe_remove, like in win_splitmove.
Make sure autocommands from switching to the altwin fire within a valid window,
and ensure they don't screw things up. Set the error message to that of
win_split_ins, if any.

Also change a few other small things, including:

- adjust win_append to take a tabpage_T * argument, which is more consistent
  with win_remove (and also allows us to undo a call to win_remove).

- allow winframe_restore to restore window positions. Useful if `wp` was in a
  different tabpage, as a call to win_comp_pos (which only works for the current
  tabpage) after winframe_restore should no longer be needed.

  Though enter_tabpage calls win_comp_pos anyway, this has the advantage of
  ensuring w_winrow/col remains accurate even before entering the tabpage
  (useful for stuff like win_screenpos, if used on a window in another tabpage).

  (This change should probably also be PR'd to Vim later, even though it doesn't
  use winframe_restore for a `wp` in a different tabpage yet).
2024-03-08 23:24:05 +00:00
Sean Dewar 832bc5c169
vim-patch:9.1.0130: [security]: UAF if win_split_ins autocommands delete "wp"
Problem:  heap-use-after-free in win_splitmove if Enter/Leave
          autocommands from win_split_ins immediately closes "wp".
Solution: check that "wp" is valid after win_split_ins.
          (Sean Dewar)

abf7030a5c
2024-03-08 23:24:05 +00:00
Sean Dewar e3d4dfb6c3
vim-patch:9.1.0128: win_gotoid() may abort even when not switching a window
Problem:  win_gotoid() checks for textlock and other things when switching
          to a window that is already current (after v9.1.0119)
Solution: return early with success when attempting to switch to curwin
          (Sean Dewar)

2a65e73944
2024-03-08 23:24:05 +00:00
Sean Dewar b2245307f2
vim-patch:9.1.0121: Infinite loop or signed overflow with 'smoothscroll'
Problem:  infinite loop in win_update with 'smoothscroll' set when
          window width is equal to textoff, or signed integer overflow
          if smaller.
Solution: don't revalidate wp->w_skipcol in that case, as no buffer text
          is being shown. (Sean Dewar)

02fcae02a9

Test_window_split_no_room changes were already cherry-picked earlier.
2024-03-08 23:24:05 +00:00
Sean Dewar 01b27410a3
vim-patch:9.1.0119: can move away from cmdwin using win_splitmove()
Problem:  can switch windows while textlocked via f_win_gotoid and
          f_win_splitmove (which also allows switching in the cmdwin).
Solution: Check text_or_buf_locked in f_win_splitmove()
          (Sean Dewar)

While at it, call text_or_buf_locked() in f_win_gotoid() instead of testing for
cmdwin_type() (which text_buf_locked() does and in addition will also verify
that the buffer is not locked).

f865895c87
2024-03-08 23:24:05 +00:00
Sean Dewar 1c6b693ec1
vim-patch:9.1.0118: Use different restoration strategy in win_splitmove
Problem:  saving and restoring all frames to split-move is overkill now
          that WinNewPre is not fired when split-moving.
Solution: defer the flattening of frames until win_split_ins begins
          reorganising them, and attempt to restore the layout by
          undoing our changes. (Sean Dewar)

704966c254

Adjust winframe_restore to account for Nvim's horizontal separators when the
global statusline is in use. Add a test.
2024-03-08 23:24:04 +00:00
Sean Dewar 24dfa47e4f
vim-patch:partial:9.1.0117: Stop split-moving from firing WinNew and WinNewPre autocommands
Problem:  win_splitmove fires WinNewPre and possibly WinNew when moving
          windows, even though no new windows are created.
Solution: don't fire WinNew and WinNewPre when inserting an existing
          window, even if it isn't the current window. Improve the
          accuracy of related documentation. (Sean Dewar)

96cc4aef3d

Partial as WinNewPre has not been ported yet (it currently has problems anyway).
2024-03-08 23:24:04 +00:00
Sean Dewar 66f331fef7
vim-patch:9.1.0116: win_split_ins may not check available room
Problem:  win_split_ins has no check for E36 when moving an existing
          window
Solution: check for room and fix the issues in f_win_splitmove()
          (Sean Dewar)

0fd44a5ad8

Omit WSP_FORCE_ROOM, as it's not needed for Nvim's autocmd window, which is
floating. Shouldn't be difficult to port later if it's used for anything else.

Make win_splitmove continue working for turning floating windows into splits.
Move the logic for "unfloating" a float to win_split_ins; unlike splits, no
changes to the window layout are needed before calling it, as floats take no
room in the window layout and cannot affect the e_noroom check.

Add missing tp_curwin-fixing logic for turning external windows into splits, and
add a test.
NOTE: there are other issues with the way "tabpage independence" is implemented
for external windows; namely, some things assume that tp_curwin is indeed a
window within that tabpage, and as such, functions like tabpage_winnr and
nvim_tabpage_get_win currently don't always work for external windows (with the
latter aborting!)

Use last_status over frame_add_statusline, as Nvim's last_status already does
this for all windows in the current tabpage. Adjust restore_full_snapshot_rec to
handle this.
This "restore everything" approach is changed in a future commit anyway, so only
ensure it's robust enough to just pass tests.

Keep check_split_disallowed's current doc comment, as it's actually a bit more
accurate here. (I should probably PR Vim to use this one)

Allow f_win_splitmove to move a floating "wp" into a split; Nvim supports this.
Continue to disallow it from moving the autocommand window into a split (funnily
enough, the check wasn't reachable before, as moving a float was disallowed),
but now return -1 in that case (win_splitmove also returns FAIL for this, but
handling it in f_win_splitmove avoids us needing to switch windows first).

Cherry-pick Test_window_split_no_room fix from v9.1.0121.

Update nvim_win_set_config to handle win_split_ins failure in later commits.
2024-03-08 23:24:04 +00:00
Sean Dewar a70eae57bd
fix(api): make open_win block only enter/leave events if !enter && !noautocmd
Problem: nvim_open_win blocking all win_set_buf autocommands when !enter &&
!noautocmd is too aggressive.

Solution: temporarily block WinEnter/Leave and BufEnter/Leave events when
setting the buffer. Delegate the firing of BufWinEnter back to win_set_buf,
which also has the advantage of keeping the timing consistent (e.g: before the
epilogue in enter_buffer, which also handles restoring the cursor position if
autocommands didn't change it, among other things). Reword the documentation for
noautocmd a bit.

I pondered modifying do_buffer and callees to allow for BufEnter/Leave being
conditionally disabled, but it seems too invasive (and potentially error-prone,
especially if new code paths to BufEnter/Leave are added in the future).

Unfortunately, doing this has the drawback of blocking ALL such events for the
duration, which also means blocking unrelated such events; like if window
switching occurs in a ++nested autocmd fired by win_set_buf. If this turns out
to be a problem in practice, a different solution specialized for nvim_open_win
could be considered. :-)
2024-03-08 23:24:04 +00:00
Sean Dewar b1577d371a
fix(api): make win_set_config with "win" for splits need "split/vertical"
Problem: currently, for splits, nvim_win_set_config accepts win without any of
split or vertical set, which has little effect and seems error-prone.

Solution: require at least one of split or vertical to also be set for splits.

Also, update nvim_win_set_config docs, as it's no longer limited to just
floating and external windows.
2024-03-08 23:24:04 +00:00
Sean Dewar 5d58136ccc
fix(api): make open_win/win_set_config check if splitting allowed
Problem: splitting is disallowed in some cases to prevent the window layout
changes while a window is closing, but it's not checked for.

Solution: check for this, and set the API error message directly.

(Also sneak in a change to tui.c that got lost from #27352; it's a char* buf,
and the memset is assuming one byte each anyway)
2024-03-08 23:24:03 +00:00
Sean Dewar b1e24f240b
fix(api): avoid open_win UAF if target buf deleted by autocmds
Problem: WinNew and win_enter autocommands can delete the target buffer to
switch to, causing a heap-use-after-free.

Solution: store a bufref to the buffer, check it before attempting to switch.
2024-03-08 23:24:03 +00:00
Sean Dewar e55a502ed4
fix(api): open_win fire Buf* events when !enter && !noautocmd if entered early
Problem: if switch_win{_noblock} fails to restore the old curwin after WinNew
(e.g: it was closed), wp will become the new curwin, but win_set_buf enter
events would still be blocked if !enter && !noautocmd.

Solution: fire them, as we've actually entered the new window.

Note: there's a problem of switch_win{_noblock} failing to restore the old
curwin, leaving us in wp without triggering WinEnter/WinLeave, but this affects
all callers of switch_win{_noblock} anyways. (It's also not clear how WinLeave
can be called if the old curwin was closed already).
2024-03-08 23:24:00 +00:00
Sean Dewar a873f33993
fix(api): open_win fire BufWinEnter for other buffer when !enter && !noautocmd
Problem: BufWinEnter is not fired when not entering a new window, even when a
different buffer is specified and buffer-related autocommands are unblocked
(!noautocmd).

Solution: fire it in the context of the new window and buffer. Do not do it if
the buffer is unchanged, like :{s}buffer.

Be wary of autocommands! For example, it's possible for nvim_win_set_config to
be used in an autocommand to move a window to a different tabpage (in contrast,
things like wincmd T actually create a *new* window, so it may not have been
possible before, meaning other parts of Nvim could assume windows can't do
this... I'd be especially cautious of logic that restores curwin and curtab
without checking if curwin is still valid in curtab, if any such logic exists).

Also, bail early from win_set_buf if setting the temp curwin fails; this
shouldn't be possible, as the callers check that wp is valid, but in case that's
not true, win_set_buf will no longer continue setting a buffer for the wrong
window.

Note that pum_create_float_preview also uses win_set_buf, but from a glance,
doesn't look like it properly checks for autocmds screwing things up (win_enter,
nvim_create_buf...). I haven't addressed that here.

Also adds some test coverage for nvim_open_win autocommands.

Closes #27121.
2024-03-08 23:23:55 +00:00
Sean Dewar 233649bc75
fix(api): win_set_config fires unnecessary autocmds
Problem: win_set_config should have the observable effect of moving an existing
window to another place, but instead fires autocommands as if a new window was
created and entered (and does not fire autocommands reflecting a "return" to the
original window).

Solution: do not fire win_enter-related autocommands when splitting the window,
but continue to fire them when entering the window that fills the new space when
moving a window to a different tabpage, as the new curwin changes.

Also, remove "++once" from the WinEnter autocmd in the other test, as omitting
it also crashed Nvim before this fix.
2024-03-08 22:37:32 +00:00
Sean Dewar bcb70eeac4
fix(api): win_set_config autocmds crash when moving win to other tabpage
Problem: win_enter autocommands can close new_curwin, crashing if it was the
last window in its tabpage after removing win, or can close parent, crashing
when attempting to split it later.

Solution: remove win first, check that parent is valid after win_enter.

NOTE: This isn't actually quite right, as this means win is not in the window
list or even has a frame when triggering enter autocommands (so it's not
considered valid in the tabpage). This is addressed in later commits.
2024-03-08 22:37:31 +00:00
Colin Watson a69c720639
fix(fileio): fix off-by-one in rename_with_tmp (#27780)
`_FORTIFY_SOURCE` on Ubuntu caught this, resulting in:

    [OLDTEST] Running test_rename
    Failed: test_rename :: Nvim exited with non-zero code
    Job exited with code 134
    Screen (23 lines)
    ================================================================================
    "test_rename.vim" "test_rename.vim" 120L, 3623B
    Executing Test_rename_copy()
    Executing Test_rename_dir_to_dir()
    Executing Test_rename_fails()
    Error detected while processing command line..script /<<BUILDDIR>>/neovim-0.9.5/test/old/testdir/runtest.vim[437]..function RunTheTest[44]..Test_rename_fails:
    line   17:
    E730: using List as a String
    line   18:
    E976: using Blob as a String
    Executing Test_rename_file_ignore_case()*** buffer overflow detected ***: terminated

`snprintf`'s second parameter should be no greater than the number of
remaining bytes in the allocated object.  We can see that this was off
by one, because in the simple case where `tail == tempname` (for a file
in the current directory), `rename_with_tmp` was passing `MAXPATHL + 2`
for an object allocated with a size of only `MAXPATHL + 1`.

Introduced in 5f1a153831.
2024-03-09 05:49:06 +08:00
bfredl e534ec47db refactor(ui): remove outdated UI vs UIData distinction
Just some basic spring cleaning.

In the distant past, not all UI:s where remote UI:s. They still aren't,
but both of the "UI" and "UIData" structs are now only for remote UI:s.
Thus join them as "RemoteUI".
2024-03-08 09:23:28 +01:00
bfredl 55c9e2c96e
Merge pull request #27655 from bfredl/mpack_obj
refactor(msgpack): allow flushing buffer while packing msgpack
2024-03-08 08:57:09 +01:00
zeertzjq 6a580b997b
vim-patch:8.2.5077: various warnings from clang on MS-Windows (#27773)
Problem:    Various warnings from clang on MS-Windows.
Solution:   Avoid the warnings. (Yegappan Lakshmanan, closes vim/vim#10553)

a34b4460c2

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-03-08 13:56:27 +08:00
zeertzjq d0b3c87219
fix(process): avoid potential data race on exit (#27769)
On exit, pty_process_close() may be called after pty_process_finish1()
but before start_wait_eof_timer(), in which case the timer shouldn't be
started because pty_process_close() has already closed it.
2024-03-08 09:18:03 +08:00
zeertzjq c38764182a vim-patch:9.1.0158: 'shortmess' "F" flag doesn't work properly with 'autoread'
Problem:  'shortmess' "F" flag doesn't work properly with 'autoread'
          (after 9.1.0154)
Solution: Hide the file info message instead of the warning dialog
          (zeertzjq)

closes: vim/vim#14159
closes: vim/vim#14158

8a01744c56
2024-03-08 07:04:39 +08:00
zeertzjq d741e5d162 vim-patch:9.1.0154: shm=F not respected when reloading buffer with 'autoread'
Problem:  shm=F not respected when reloading buffer with 'autoread'
Solution: Check SHM_FILEINFO in buf_check_timestamp()
          (Shougo Matsushita)

closes: vim/vim#14144

9db39b0ec9

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2024-03-08 06:53:37 +08:00
zeertzjq 5f3579e6ea
vim-patch:9.1.0157: Duplicate assignment in f_getregion() (#27766)
Problem:  Duplicate assignment in f_getregion().
Solution: Remove the duplicate assignment.  Also improve getregion()
          docs wording and fix an unrelated typo (zeertzjq)

closes: vim/vim#14154

0df8f93bda
2024-03-08 06:44:57 +08:00
zeertzjq 3e569d440b
fix(process): close handles and timer in pty_process_close() (#27760)
This should prevent use-after-free on exit on Windows.
2024-03-07 18:05:55 +08:00
bfredl dc37c1550b refactor(msgpack): allow flushing buffer while packing msgpack
Before, we needed to always pack an entire msgpack_rpc Object to
a continous memory buffer before sending it out to a channel.
But this is generally wasteful. it is better to just flush
whatever is in the buffer and then continue packing to a new buffer.

This is also done for the UI event packer where there are some extra logic
to "finish" of an existing batch of nevents/ncalls. This doesn't really
stop us from flushing the buffer, just that we need to update the state
machine accordingly so the next call to prepare_call() always will
start with a new event (even though the buffer might contain overflow
data from a large event).
2024-03-07 09:39:46 +01:00
zeertzjq 6525832a8c
vim-patch:9.1.0155: can only get getregion() from current buffer (#27757)
Problem:  can only call getregion() for current buffer
Solution: Allow to retrieve selections from different buffers
          (Shougo Matsushita)

closes: vim/vim#14131

84bf6e658d

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2024-03-07 06:43:08 +08:00
zeertzjq 5b312cd5f6
fix(eval): make has('pythonx') work properly (#27739)
Problem:  has('pythonx') always returns 1.
Solution: Make it the same as has('python3').
2024-03-05 15:54:41 +08:00
Sean Dewar 633bf61d3b
fix(ui_client): check return value of channel_job_start (#27729)
Problem: null pointer member access in ui_client_start_server if
channel_job_start returns NULL.

Solution: check for it, return 0 in that case (which is already used to indicate
failure and is handled by main).

Happened on Linux when trying to run Nvim in an old gdbserver instance after having
rebuilt Nvim since. This gave E903 (the nvim binary was deleted, so " (deleted)" appears
as a suffix in the `v:progpath`, making it invalid), then ASAN complains due to the NPD;
instead it now then prints "Failed to start Nvim server!", as expected.
2024-03-04 13:15:04 +00:00
Sean Dewar bf0c69e504
fix(eval): correct failure return value for readfile/blob (#27722)
Currently returns 0 on failure, but should return an empty list (or blob).

Regressed in the big blob port of '21 (#15211).
2024-03-03 22:33:28 +00:00
luukvbaal dbf6be296d
fix(column): full redraw with 'stc, 'rnu' and inserted lines (#27712)
Problem:  Text is not redrawn with 'relativenumber' when only the 'statuscolumn' is redrawn after inserted lines.
Solution: Force a full redraw if statuscolumn width changed.
2024-03-03 08:40:46 +08:00
bfredl 0d553c8347
Merge pull request #27687 from luukvbaal/floatpos
fix(float): allow floating window in cmdline area
2024-03-02 11:22:40 +01:00
zeertzjq 62d04f21d9
vim-patch:9.1.0146: v:echospace wrong with invalid value of 'showcmdloc' (#27697)
Problem:  v:echospace wrong after setting invalid value to 'showcmdloc'.
Solution: Only call comp_col() if value is valid.
          (zeertzjq)

closes: vim/vim#14119

c27fcf4857
2024-03-02 06:48:11 +08:00
zeertzjq 1fe65b3457
vim-patch:87410ab3f556 (#27696)
runtime(doc): some improvements to getregion() docs (vim/vim#14122)

- Mention the default selection behavior
- Remove useless sentence
- Correct description about space padding

87410ab3f5
2024-03-02 06:42:39 +08:00
Luuk van Baal 884470124d fix(float): allow floating window in cmdline area
Problem:  Floats are arbitrarily positioned at 1 row above screen size.
Solution: Position at 1 row above 'cmdheight', only if window is hidden behind the message area.
2024-03-01 16:00:16 +01:00
zeertzjq 5d4e1693cb
vim-patch:9.1.0145: v:echospace not correct when 'showcmdloc' != last (#27682)
Problem:  the amount of available space (v:echospace) on the command
          line is not correct when showcmdloc is drawn into the
          statusline or tabline.
Solution: only add SHOWCMD_COLS to the shown command column when
          'showcmdloc' is set to last (Sam-programs)

closes: vim/vim#14108

062141b1a7

Co-authored-by: Sam-programs <130783534+Sam-programs@users.noreply.github.com>
2024-03-01 06:13:38 +08:00
glepnir 6ab0876f51 docs(eval): getline and indent function support string type
Problem: getline and indent function missing string type in param.

Solution: add string type in eval gen.
2024-02-29 13:30:25 +00:00
zeertzjq 0eaae1bc05
vim-patch:9.1.0143: [security]: autocmd causes use-after-free in set_curbuf() (#27664)
Problem:  [security]: autocmd cause use-after-free in set_curbuf()
          (kawarimidoll)
Solution: check side-effect of BufLeave autocommand, when the number
          of windows changed, close windows containing buffers that will
          be wiped, if curbuf changed unexpectedly make sure b_nwindows
          is decremented otherwise it cannot be wiped

set_curbuf() already makes some efforts to ensure the BufLeave
autocommands do not cause issues.  However there are still 2 issues
that are not taken care of:

1) If a BufLeave autocommand opens a new window containing the same
buffer as that is going got be closed in close_buffer() a bit later,
we suddenly have another window open, containing a free'd buffer.  So we
must check if the number of windows changed and if it does (and the
current buffer is going to be wiped (according to the 'bufhidden'
setting), let's immediately close all windows containing the current
buffer using close_windows()

2) If a BufLeave autocommand changes our current buffer (displays it in
the current window), buf->b_nwindow will be incremented. As part of
set_curbuf() we will however enter another buffer soon, which means, the
newly created curbuf will have b_nwindows still have set, even so the
buffer is no longer displayed in a window. This causes later problems,
because it will no longer be possible to wipe such a buffer. So just
before entering the final buffer, check if the curbuf changed when
calling the BufLeave autocommand and if it does (and curbuf is still
valid), decrement curbuf->b_nwindows.

Both issues can be verified using the provided test (however the second
issue only because such an impacted buffer won't be wiped, causing
futher issues in later tests).

fixes: vim/vim#13839
closes: vim/vim#14104

55f8bba73b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-29 08:33:02 +08:00
zeertzjq ce7c51a1a3
vim-patch:9.1.0142: getregion() can be improved (#27662)
Problem:  getregion() can be improved (after v9.1.120)
Solution: change getregion() implementation to use pos as lists and
          one optional {opt} dictionary (Shougo Matsushita)

Note: The following is a breaking change!

Currently, the getregion() function (included as of patch v9.1.120) takes
3 arguments: the first 2 arguments are strings, describing a position,
arg3 is the type string.

However, that is slightly inflexible, there is no way to specify
additional arguments. So let's instead change the function signature to:

getregion(pos1, pos2 [, {Dict}]) where both pos1 and pos2 are lists.
This is slightly cleaner, and gives us the flexibility to specify
additional arguments as key/value pairs to the optional Dict arg.

Now it supports the "type" key to specify the selection type
(characterwise, blockwise or linewise) and now in addition one can also
define the selection type, independently of what the 'selection' option
actually is.

Technically, this is a breaking change, but since the getregion()
Vimscript function is still quite new, this should be fine.

closes: vim/vim#14090

19b718828d

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2024-02-29 07:19:26 +08:00
zeertzjq e592657df8
vim-patch:9.1.0141: Put in Visual mode wrong if it replaces fold marker (#27661)
Problem:  Put in Visual mode wrong if it replaces fold marker.
Solution: Temporarily disable folding during put in Visual mode.
          (zeertzjq)

fixes: vim/vim#14097
closes: vim/vim#14100

4e141c66b9
2024-02-29 06:48:29 +08:00
bfredl de5cf09cf9 refactor(metadata): generate all metadata in lua
Then we can just load metadata in C as a single msgpack blob. Which also
can be used directly as binarly data, instead of first unpacking all the
functions and ui_events metadata to immediately pack it again, which was
a bit of a silly walk (and one extra usecase of `msgpack_rpc_from_object`
which will get yak shaved in the next PR)
2024-02-28 11:00:38 +01:00
zeertzjq 7e46ff791c
vim-patch:9.1.0140: cursor on wrong row after 1 char 'below' virtual text when EOL is shown (#27651)
Problem:  The cursor screen row was incorrectly being calculated when the
          cursor follows a 1 character text_align 'below' virtual text line,
          resulting in the cursor being shown on the wrong line.
          This was caused by a cell size of 2 instead of 1 being used for the EOL
          character, which propagated to the calculation of space for putting the
          'below' virtual text on its own line. (rickhowe)
Solution: Fix the size used for the EOL character in calculating the
          cursor's screen position (Dylan Thacker-Smith)

fixes: vim/vim#11959
related: vim/vim#12028
closes: vim/vim#14096

da0c9137d1

Co-authored-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
2024-02-28 07:28:48 +08:00
Lewis Russell 9beb40a4db feat(docs): replace lua2dox.lua
Problem:

The documentation flow (`gen_vimdoc.py`) has several issues:
- it's not very versatile
- depends on doxygen
- doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C.
- The intermediate XML files and filters makes it too much like a rube goldberg machine.

Solution:

Re-implement the flow using Lua, LPEG and treesitter.

- `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic.
- `lua2dox.lua` is gone!
- No more XML files.
- Doxygen is now longer used and instead we now use:
  - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`).
  - LPEG for C parsing (see `scripts/cdoc_parser.lua`)
  - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`).
  - Treesitter for Markdown parsing (see `scripts/text_utils.lua`).
- The generated `runtime/doc/*.mpack` files have been removed.
   - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly.
- Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
2024-02-27 14:41:17 +00:00
Maria José Solano 7ad2e3c645
docs: fix type of setreg() argument {options} (#27631) 2024-02-27 19:53:49 +08:00
zeertzjq 0d75324e3b
vim-patch:9.1.0137: <Del> in cmdline mode doesn't delete composing chars (#27636)
Problem:  <Del> in cmdline mode doesn't delete composing chars
Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq)

closes: vim/vim#14095

ff2b79d239
2024-02-27 06:09:06 +08:00
bfredl cdcdc10411 refactor(msgpack): remove dead unpacker code in helpers
Unpacker code now lives in unpacker.c
This was part of the old unpacker which I forgor to remove.
2024-02-26 14:47:47 +01:00
bfredl 7038fdeee2
Merge pull request #27599 from bfredl/nofilealloc
refactor(fileio): remove API shell layer encouraging unnecessary allocations
2024-02-26 14:43:42 +01:00
VanaIgr ad5a155b1f
fix(mbyte): fix bugs in utf_cp_*_off() functions
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.
2024-02-26 18:12:55 +08:00
zeertzjq 268066e014
fix(process): start pty process eof timer on main thread (#27625) 2024-02-26 09:47:49 +08:00
bfredl 7447b035ca refactor(shada): devirtualize writer
writer is only ever used with FileDescriptor. We already have separate
code paths for serializing shada data into memory, see
shada_encode_regs() and friends
2024-02-25 11:20:06 +01:00
bfredl 77e928fd3e refactor(fileio): remove API shell layer encouraging unnecessary allocations
Functions like file_open_new() and file_open_fd_new() which just is a
wrapper around the real functions but with an extra xmalloc/xfree around
is an anti-pattern. If the caller really needs to allocate a
FileDescriptor as a heap object, it can do that directly.

FileDescriptor by itself is pretty much a pointer, or rather two:
the OS fd index and a pointer to a buffer. So most of the time an extra
pointer layer is just wasteful.

In the case of scriptin[curscript] in getchar.c, curscript used
to mean in practice:

N+1 open scripts           when curscript>0
zero or one open scripts   when curscript==0

Which means scriptin[0] had to be compared to NULL to disambiguate the
curscript=0 case.

Instead, use curscript==-1 to mean that are no script,
then all pointer comparisons dissappear and we can just use an array of
structs without extra pointers.
2024-02-25 11:20:06 +01:00
Evgeni Chasnovski c2ddef30e7
docs: fix several misleading and superfluous wordings (#27609) 2024-02-25 08:45:34 +08:00
zeertzjq 04f723f1a5
vim-patch:9.1.0131: buffer-completion may not always find all matches (#27610)
Problem:  buffer-completion code too complicated and does not always
          find all matches (irisjae)
Solution: do not try to anchor pattern to beginning of line or
          directory-separator, always return all matches

Note: we are considering the non-fuzzy buffer-matching here.

Currently, the buffer-completion code makes 2 attempts to match a
pattern against the list of available patterns. First try is to match
the pattern and anchor it to either the beginning of the file name or
at a directory-separator (// or \\).

When a match is found, Vim returns the matching buffers and does not try
to find a match anywhere within a buffer name. So if you have opened two
buffers like /tmp/Foobar.c and /tmp/MyFoobar.c using `:b Foo` will only
complete to the first filename, but not the second (the same happens
with `getcompletion('Foo', 'buffer')`).

It may make sense, that completion priorities buffer names at directory
boundaries, but it inconsistent, may cause confusion why a certain
buffer name is not completed when typing `:b Foo<C-D>` which returns
only a single file name and then pressing Enter (to switch to that
buffer), Vim will error with 'E93: More than one match for Foo').
Similar things may happen when wiping the /tmp/Foobar.c pattern and
afterwards the completion starts completing other buffers.

So let's simplify the code and always match the pattern anywhere in the
buffer name, do not try to favor matches at directory boundaries. This
is also simplifies the code a bit, we do not need to run over the list
of buffers several times, but only twice.

fixes vim/vim#13894
closes: vim/vim#14082

0dc0bff000

Cherry-pick test_cmdline.vim from patch 9.1.0019 as it already passes.

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-24 22:59:28 +08:00
zeertzjq febf481002
vim-patch:9.1.0132: "C" doesn't include composing chars with 'virtualedit' (#27605)
Problem:  using "C" and 've=all' set, doesn't include composing chars
          when changing a line, keeps the composing chars for whatever
          is typed afterwards.
Solution: Use mb_head_off() and mb_ptr2len() instead of mb_tail_off().
          (zeertzjq)

closes: vim/vim#14083

048761bcd4
2024-02-24 22:04:52 +08:00
zeertzjq 9ea8a77b04
vim-patch:9.1.0129: Fix truncation of text_wrap 'wrap' virt text after EOL list char (#27600)
Problem:  Virtual text with text_wrap 'wrap' was effectively being
          truncated by a break conditional on the EOL list character
          being added to the screen line. (BigPeet)
Solution: Remove the condition that was leading to the early break and
          instead fix a similar but incorrectly written outer condition
          that checks if there is more to add at the end of the screen
          line. (Dylan Thacker-Smith)

Also, related:
- update comment in win_line()
- remove no longer necessary at_end_str variable in win_line()

fixes: vim/vim#12725
closes: vim/vim#14079

f548ae7b63

Co-authored-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
2024-02-24 20:16:39 +08:00
zeertzjq 9418381ccc
vim-patch:a35235e824bb (#27598)
runtime(doc) Update help text for matchbufline() and matchstrlist()

closes: vim/vim#14080

a35235e824

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-02-24 17:55:32 +08:00
bfredl c5990f2cdc perf(os/env): os_getenv() allocation when there is no env var set
os_getenv("FOO") caches the result when $FOO is set to something
non-empty. However, when $FOO was not set, every new call to
os_getenv("FOO") would allocate a temporary scratch buffer to
immediately throw away.

This has an huge impact e.g. on logging which depends on potentially
non-set env vars.
2024-02-24 09:30:21 +01:00
zeertzjq 99288ecc77
fix(terminal): block input when there is pending TermRequest (#27589) 2024-02-24 05:12:30 +08:00
bfredl cb5ae22eab
Merge pull request #27590 from bfredl/signcolfix
fix(marktree): do not count certain marks twice when checking for overlap
2024-02-23 13:37:11 +01:00
bfredl b97d5038f1 fix(marktree): some marks counted twice when checking for overlap
fixes #27046
2024-02-23 11:41:09 +01:00
zeertzjq 1f75184b5c vim-patch:9.1.0127: Naming a non-pointer variable "oap" is strange
Problem:  Naming a non-pointer variable "oap" is strange.
Solution: Rename it to "oa". Also prevent using freed memory in case of
          memory allocation failure. (zeertzjq)

closes: vim/vim#14075

5e3674b42d
2024-02-23 06:39:34 +08:00
zeertzjq 06df895e71 vim-patch:9.1.0126: Internal error when using upper-case mark in getregion()
Problem:  Internal error when passing mark in another buffer to
          getregion().
Solution: Don't allow marks in another buffer (zeertzjq)

closes: vim/vim#14076

Internal error when passing mark in another buffer to getregion()

421b597470
2024-02-23 06:39:05 +08:00
zeertzjq 20e4001eee vim-patch:9.1.0120: hard to get visual region using Vim script
Problem:  hard to get visual region using Vim script
Solution: Add getregion() Vim script function
          (Shougo Matsushita, Jakub Łuczyński)

closes: vim/vim#13998
closes: vim/vim#11579

3f905ab3c4

Cherry-pick changes from patch 9.1.0122, with :echom instead of :echow.

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Co-authored-by: Jakub Łuczyński <doubleloop@o2.pl>
2024-02-23 06:39:03 +08:00
zeertzjq 4ec5c58846
refactor(terminal): rename confusing variable name "rv" (#27573)
Now that terminal_open() no longer returns a value, the variable name
"rv" is confusing, and "term" makes more sense anyway.
2024-02-22 13:18:52 +08:00
zeertzjq 711a2f5ff6
fix(api): don't leak memory with nvim_win_get_ns (#27570) 2024-02-22 09:13:07 +08:00
zeertzjq 2137edbd4f
fix(extmarks): redraw properly with scoped inline virt_text (#27569) 2024-02-22 09:05:52 +08:00
altermo 1c032ad703 feat(extmark): window scoped extmark
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-02-21 16:11:50 +01:00
rktjmp 6d8bbfe19d
docs: remove mention of foreground/background/special keys in nvim_set_hl (#27558)
To align the output of `nvim_get_hl` with its documentation -- which
points to `nvim_set_hl`, remove mentions of the keys `foreground`,
`background` and `special`.

The long keys are are still supported (via fallback checks inside
`dict2hlattrs`), but the `fg`, `bg` and `sp` keys are preferenced.
2024-02-21 21:25:08 +08:00
dundargoc 4fb1739e6f build: fix uncrustify 2024-02-21 11:58:28 +01:00
bfredl 3cc54586be refactor(api): make freeing of return-value opt-in instead of opt out
As only a few API functions make use of explicit freeing of the return
value, make it opt-in instead. The arena is always present under the
hood, so `Arena *arena` arg now doesn't mean anything other than getting
access to this arena. Also it is in principle possible to return an
allocated value while still using the arena as scratch space for other
stuff (unlikely, but there no reason to not allow it).
2024-02-21 11:58:28 +01:00
bfredl eb1e8c12e2
Merge pull request #27541 from bfredl/exprarena
refactor(api): use an arena for nvim_parse_expression
2024-02-20 13:11:18 +01:00
zeertzjq a0790558c3
fix(extmarks): priority order of inline and non-inline virt_text (#27532) 2024-02-20 19:53:49 +08:00
bfredl acd9b54f08 refactor(api): use an arena for nvim_parse_expression 2024-02-20 12:31:11 +01:00
bfredl f2c73e9ee2 refactor(api): reduce temporary allocations when replacing lines
The way ml_replace_buf is implemented makes it unfriendly for
being used in a loop: every call allocates a scratch buffer for putting
the line into the "dirty" state. This then immediately needs to be freed
as the next ml_replace_buf and/or ml_append_buf call will flush that buffer.

It's better to later pay the price of allocating the scratch buffer only if
the line is being immediately edited (likely when using the API to only
change one line) with an extra memcpy, than allocating that buffer
multiple times every time the API is called.

Of course, a separate xmalloc/xfree cycle for each time the dirty line
changes is unwanted to begin with. But fixing that is a later refactor.
2024-02-20 11:24:15 +01:00
bfredl 8952a89db5
Merge pull request #27534 from bfredl/userarena
refactor(api): next PR to make use of the arena
2024-02-19 21:21:05 +01:00
dundargoc 8fdc84d0aa build: disable conversion warnings for GCC
GCC seems chronically incapable of producing correct and relevant
conversion warnings, and will therefore need to be silenced.
2024-02-19 20:41:44 +01:00
bfredl 404707c760 refactor(api): use arena for nvim_put and nvim_paste 2024-02-19 13:48:39 +01:00
bfredl d14eefaee9 refactor(api): use arena when listing objects 2024-02-19 13:48:39 +01:00
bfredl abb8dcd889 refactor(api): use arena for runtime and client info 2024-02-19 13:48:39 +01:00
bfredl 1d95abc66b refactor(api): use an arena for user commands 2024-02-19 13:44:45 +01:00
zeertzjq a9f578b7a5
docs: improve 'tabline' click label docs (#27529) 2024-02-19 11:22:00 +08:00
Nacho Nieva fa131de9ad
feat(tabline): middle mouse button now closes tab (#27522) 2024-02-19 10:49:33 +08:00
zeertzjq 8f1f2a1d9f
vim-patch:9.1.0115: Using freed memory with full tag stack and user data (#27525)
Problem:  Using freed memory with full tag stack and user data
          (Konstantin Khlebnikov)
Solution: Clear the user data pointer of the newest entry.
          (zeertzjq, Konstantin Khlebnikov)

fixes: neovim/neovim#27498
closes: vim/vim#14053

c86bff1771

Cherry-pick Test_tag_stack() changes from patch 9.0.0767.

Co-authored-by: Konstantin Khlebnikov <koct9i@gmail.com>
2024-02-19 06:53:13 +08:00
bfredl bbf6d4a4bc refactor(api): use arena for metadata; msgpack_rpc_to_object delenda est
Note: kSDItemHeader is something is _written_ by nvim in the shada file
to identify it for debugging purposes outside of nvim. But this data wasn't ever used by
neovim after reading the file back, So I removed the parsing of it for now.
2024-02-18 18:09:56 +01:00
bfredl 93c911e52f
Merge pull request #27511 from bfredl/maparena
refactor(api): use arena for mappings, autocmd, channel info
2024-02-18 18:04:28 +01:00
bfredl 97531be1f7 refactor(api): use arena for autocmds 2024-02-18 13:38:19 +01:00
zeertzjq b8c34efe33
fix(eval): skip over v:lua properly (#27517)
Problem:  Error when parsing v:lua in a ternary expression.
Solution: Set rettv->v_type for v:lua even if not evaluating.
2024-02-18 19:11:44 +08:00
zeertzjq 796df966f3
fix(options): don't update curswant for 'winhl' or 'winbl' (#27515) 2024-02-18 18:11:20 +08:00
bfredl 146333ca12 refactor(api): use arena for channel info and terminal info 2024-02-18 10:36:07 +01:00
zeertzjq eb8a3e0575
vim-patch:9.1.0114: Setting some options may change curswant (#27514)
Problem:  Setting some options changes curswant unnecessarily.
Solution: Add a P_HLONLY flag that prevents changing curswant.
          (zeertzjq)

closes: vim/vim#14044

fcaed6a70f
2024-02-18 17:20:49 +08:00
bfredl f25fcc68a3 refactor(api): use an arena for mappings 2024-02-18 10:15:27 +01:00
bfredl 2accf24805 fix(decorations): crash with revised mark with changed decoration flags
fixes #27211
2024-02-17 18:22:35 +01:00
luukvbaal 5fd1bac65e
fix(api): don't use stl 'fillchar' for "use_statuscol_lnum" (#27501)
Problem:  nvim_eval_statusline() uses "stl" from 'fillchars' with "use_statuscol_lnum".
Solution: Reorder "fillchar" else chain.
2024-02-17 07:44:31 +08:00
Thomas Vigouroux bd5008de07
fix(treesitter): correctly handle query quantifiers (#24738)
Query patterns can contain quantifiers (e.g. (foo)+ @bar), so a single
capture can map to multiple nodes. The iter_matches API can not handle
this situation because the match table incorrectly maps capture indices
to a single node instead of to an array of nodes.

The match table should be updated to map capture indices to an array of
nodes. However, this is a massively breaking change, so must be done
with a proper deprecation period.

`iter_matches`, `add_predicate` and `add_directive` must opt-in to the
correct behavior for backward compatibility. This is done with a new
"all" option. This option will become the default and removed after the
0.10 release.

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
Co-authored-by: MDeiml <matthias@deiml.net>
Co-authored-by: Gregory Anders <greg@gpanders.com>
2024-02-16 11:54:47 -06:00
zeertzjq 51ea753747
fix(genvimvim): generate prefixed boolean options properly (#27487) 2024-02-16 13:27:42 +08:00
Gregory Anders 55a4aa41bb
docs: document breaking change for nvim_create_autocmd callback (#27484)
https://github.com/neovim/neovim/pull/27428 changed the semantics of
callbacks passed to nvim_create_autocmd such that any truthy value will
delete the autocommand (rather than just the literal boolean value
`true`). Update the documentation accordingly and add an entry to
`news.txt`.

The behavior is now consistent between nvim_create_autocmd and
nvim_buf_attach.
2024-02-15 19:56:58 -06:00
zeertzjq 163add40b8 vim-patch:9.1.0113: duplicate code when cleaning undo stack
Problem:  duplicate code when cleaning undo stack
Solution: refactor undo cleanup into a single public function

related: vim/vim#13928

9071ed8107

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-16 07:18:06 +08:00
zeertzjq c1fa8789c1 vim-patch:9.1.0112: Remove undo information, when cleaning quickfix buffer
Problem:  When the quickfix buffer has been modified an autocommand
          may invalidate the undo stack (kawarimidoll)
Solution: When clearing the quickfix buffer, also wipe the undo stack

fixes: vim/vim#13905
closes: vim/vim#13928

f0d3d4a426

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-16 07:18:06 +08:00
bfredl d60412b18e refactor(eval): use arena when converting typvals to Object
Note: this contains two _temporary_ changes which can be reverted
once the Arena vs no-Arena distinction in API wrappers has been removed.
Both nlua_push_Object and object_to_vim_take_luaref() has been changed
to take the object argument as a pointer. This is not going to be
necessary once these are only used with arena (or not at all) allocated
Objects.

The object_to_vim() variant which leaves luaref untouched might need to
stay for a little longer.
2024-02-15 10:42:06 +01:00
zeertzjq a376d979bd
fix(extmarks): redraw line on adding/removing conceal (#27463) 2024-02-14 07:51:04 +08:00
zeertzjq b2f7a3aaad
vim-patch:9.1.0105: Style: typos found (#27462)
Problem:  Style: typos found
Solution: correct them
          (zeertzjq)

closes: vim/vim#14023

e71022082d
2024-02-14 06:39:47 +08:00
bfredl 1a3a8d903e refactor(lua): use a keyset for vim.diff opts parsing 2024-02-13 11:54:44 +01:00
bfredl 0353dd3029 refactor(lua): use Arena when converting from lua stack to API args
and for return value of nlua_exec/nlua_call_ref, as this uses
the same family of functions.

NB: the handling of luaref:s is a bit of a mess.
add api_luarefs_free_XX functions as a stop-gap as refactoring
luarefs is a can of worms for another PR:s.

as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves
arbitrary return values.
2024-02-13 11:54:44 +01:00
Maria José Solano 1c7b0b9d5f
docs: stricter bufname and bufnr types (#27454) 2024-02-13 12:15:27 +08:00
zeertzjq 4860cc5bdc
vim-patch:9.1.0101: upper-case of German sharp s should be U+1E9E (#27449)
Problem:  upper-case of ß should be U+1E9E (CAPITAL LETTER SHARP S)
          (fenuks)
Solution: Make gU, ~ and g~ convert the U+00DF LATIN SMALL LETTER SHARP S (ß)
          to U+1E9E LATIN CAPITAL LETTER SHARP S (ẞ), update tests
          (glepnir)

This is part of Unicode 5.1.0 from April 2008, so should be fairly safe
to use now and since 2017 is part of the German standard orthography,
according to Wikipedia:
https://en.wikipedia.org/wiki/Capital_%E1%BA%9E#cite_note-auto-12

There is however one exception: UnicodeData.txt for U+00DF
LATIN SMALL LETTER SHARP S does NOT define U+1E9E LATIN CAPITAL LETTER
SHARP S as its upper case version. Therefore, toupper() won't be able
to convert from lower sharp s to upper case sharp s (the other way
around however works, since U+00DF is considered the lower case
character of U+1E9E and therefore tolower() works correctly for the
upper case version).

fixes: vim/vim#5573
closes: vim/vim#14018

bd1232a1fa

Co-authored-by: glepnir <glephunter@gmail.com>
2024-02-13 07:38:12 +08:00
zeertzjq 86458dde0e
vim-patch:9.1.0103: 'breakindentopt' "min" not correct with 'signcolumn' (#27451)
Problem:  'breakindentopt' "min" works incorrectly with 'signcolumn'.
Solution: Use win_col_off() and win_col_off2().
          (zeertzjq)

closes: vim/vim#14014

f0a9d65e0a
2024-02-13 07:33:24 +08:00
zeertzjq 2493fd020d
vim-patch:9.1.0102: settabvar() may change the last accessed tabpage (#27450)
Problem:  settabvar() may change the last accessed tabpage.
Solution: Save and restore lastused_tabpage.
          (zeertzjq)

closes: vim/vim#14017

b47fbb4083
2024-02-13 07:27:27 +08:00
zeertzjq 94085cfce8
perf(redraw): reduce redraw with undo and extmarks or 'spell' (#27442)
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

f2d90a3511
2024-02-13 06:56:19 +08:00
zeertzjq 984f7a9fd3
vim-patch:9.0.0245: mechanism to prevent recursive screen updating is 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)

471c0fa3ee

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-02-13 06:30:35 +08:00
bfredl 84b6ade415
Merge pull request #27439 from bfredl/nofreeallmem
fix(exitfree): don't use ex commands to close windows in free_all_mem()
2024-02-12 16:50:38 +01:00
bfredl 210ec3b7a9
Merge pull request #27348 from fredizzimo/fsundvik/fix-ext-hlstate
fix: crashes with large msgpack messages
2024-02-12 14:33:34 +01:00
zeertzjq 2d9e063a63
fix(extmarks): redraw pre-undo position (#27437)
Problem:
Virtual text not redrawn properly after undo moves its extmark.

Solution:
Redraw the moved extmark's pre-undo position.
2024-02-12 21:24:28 +08:00
bfredl f1dd75c2af fix(exitfree): don't use ex commands to close windows in free_all_mem()
Attempting to manipulate the window layout via ex commands is not safe
here. It is also redundant: `win_free_all()` can free multiple windows
by itself perfectly fine.
2024-02-12 12:20:12 +01:00
Raphael 4682f158a0
vim-patch:9.1.0098: CompleteChanged not triggered when new leader added without matches (#27436)
Problem:  CompleteChanged not triggered when new leader added causing
          no matching item in the completion menu
Solution: When completion is active but no items matched still trigger
          CompleteChanged event
          (glepnir)

closes: vim/vim#13982

0d3c0a66a3

Fix #15077
2024-02-12 14:57:13 +08:00
zeertzjq 929e1b7f1c
perf(extmarks): avoid unnecessary invalidations for virt_text (#27435)
Invalidation of most w_valid flags isn't needed when adding or removing
virtual text below cursor.
2024-02-12 13:02:27 +08:00
luukvbaal 5a4e0b837f
fix(column): use a single path for sign sorting (#27431)
Problem:  #25826 added a (duplicate) sign comparison function, which was
modified and strayed from the original in #27418.
Solution: Merge the two functions and add a display test that actually
tests for this order in addition to the legacy tests.
2024-02-12 06:41:44 +08:00
zeertzjq 9605cfe06c
vim-patch:9.1.0097: 'breakindent' behaves inconsistently with 'list' and splits (#27432)
Problem:  'breakindent' behaves inconsistently with 'list' and splits.
Solution: Use 'listchars' from the correct window and handle caching
          properly. Move cheaper comparisons to the top.
          (zeertzjq)

closes: vim/vim#14008

efabd7c8d4
2024-02-12 06:34:16 +08:00
VanaIgr 3faedb0509
refactor(indent): refactor computing of a string's indent size (#27252)
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.
2024-02-12 04:17:15 +08:00
bfredl 930d6e38d4 refactor(api): use an arena for nvim_buf_get_lines and buffer updates
Refactor some earlier "temporary Array" code in buffer_updates.c to use
the modern style of MAXSIZE_TEMP_ARRAY and ADD_C
2024-02-11 11:37:55 +01:00
zeertzjq ca258db156
fix(messages): clear new lines when increasing 'cmdheight' (#27421) 2024-02-11 18:12:56 +08:00
Trevor Arjeski 170c890dca
feat(shortmess): "q" flag fully hides recording message (#27415)
When "q" is set in 'shortmess' it now fully hides the "recording @a" message
when you are recording a macro instead of just shortening to "recording". This
removes duplication when using reg_recording() in the statusline.

Related #19193
2024-02-11 07:39:39 +08:00
Will Hopkins f1f8fa850f
refactor: rename w_float_config to w_config #27419
Follows up on rename of `FloatConfig` to `WinConfig` in #27397.
2024-02-10 13:06:01 -08:00
zeertzjq 00e785b17f refactor: don't use subtraction in qsort() comparison functions 2024-02-10 21:55:57 +08:00
zeertzjq f3982ad3f3 vim-patch:9.1.0093: Still a qsort() comparison function that returns result of subtraction
Problem:  Still a qsort() comparison function fuzzy_match_item_compare()
          that returns result of subtraction (after 9.1.0089).
Solution: Use an explicit comparison instead of subtraction.
          (zeertzjq)

closes: vim/vim#14004

77078276bf
2024-02-10 21:55:54 +08:00
zeertzjq 5bbb733a1b vim-patch:9.1.0089: qsort() comparison functions should be transitive
Problem:  qsort() comparison functions should be transitive
Solution: Do not subtract values, but rather use explicit comparisons

Improve qsort() comparison functions

There has been a recent report on qsort() causing out-of-bounds read &
write in glibc for non transitive comparison functions
https://www.qualys.com/2024/01/30/qsort.txt

Even so the bug is in glibc's implementation of the qsort() algorithm,
it's bad style to just use substraction for the comparison functions,
which may cause overflow issues and as hinted at in OpenBSD's manual
page for qsort(): "It is almost always an error to use subtraction to
compute the return value of the comparison function."

So check the qsort() comparison functions and change them to be safe.

closes: vim/vim#13980

e06e437665

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-10 21:55:51 +08:00
Justin M. Keyes e15dfb5f79
refactor: reduce some globals #27406 2024-02-10 05:00:17 -08:00
bfredl 607606e3bb
Merge pull request #27398 from bfredl/arena2
refactor(api): use arena for more stuff
2024-02-10 12:07:37 +01:00
Raphael 7ab003ec79
vim-patch:9.1.0087: Restoring lastused_tabpage too early in do_arg_all() (#27411)
Problem:  Restore lastused_tabpage too early in do_arg_all() function it
          will change later in the function.
Solution: Restore lastused_tabpage a bit later, when being done with
          tabpages (glepnir)

closes: vim/vim#13992

2975a54f28
2024-02-10 12:21:31 +08:00
zeertzjq dcb11c1091
build(clint): don't allow INIT() in non-header files (#27407) 2024-02-10 11:11:30 +08:00
Pablo Arias 8e739af064
fix(startup): multiprocess startuptime #26790
Problem:
Since 2448816956, the --startuptime report shows
two blocks of data. The TUI process and its embedded nvim process write to the
file concurrently, which may interleave the two startup sequences into the same
timeline.

Solution:
Report each process as a separate section in the same file.
1. Each process buffers the full report.
2. After startup is finished, the buffer is flushed (appended) to the file.

Fix #23036
Sample report:

    --- Startup times for process: Primary/TUI ---

    times in msec
     clock   self+sourced   self:  sourced script
     clock   elapsed:              other lines

    000.006  000.006: --- NVIM STARTING ---
    000.428  000.422: event init
    000.728  000.301: early init
    ...
    005.880  000.713: init highlight
    005.882  000.002: --- NVIM STARTED ---

    --- Startup times for process: Embedded ---

    times in msec
     clock   self+sourced   self:  sourced script
     clock   elapsed:              other lines

    000.006  000.006: --- NVIM STARTING ---
    000.409  000.403: event init
    000.557  000.148: early init
    000.633  000.077: locale set
    ...
    014.383  000.430: first screen update
    014.387  000.003: --- NVIM STARTED ---
2024-02-09 14:56:52 -08:00
zeertzjq 3f419d84fb
vim-patch:9.1.0088: TextChanged not triggered for :norm! commands (#27405)
Problem:  TextChanged not triggered for :norm! commands
          (machakann, after v9.0.2031)
Solution: Only reset curbuf->b_last_changedtick if TextChangedI
          was triggered in insert mode (and not blocked)

Note: for unknown reasons, the test fails on Windows (but seems to work
fine when running interactively)

fixes: vim/vim#13967
closes: vim/vim#13984

c9e79e5284

Cherry-pick test_autocmd.vim change from patch 8.2.4149.

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-02-10 06:53:26 +08:00
bfredl 2d0e29614b refactor(api): use arena for nvim_get_option_info() 2024-02-09 19:30:35 +01:00
bfredl 2d8d35f838 refactor(api): use arena for nvim_parse_cmd() 2024-02-09 18:24:40 +01:00
bfredl 4cd43933d3 refactor(api): use arena for hlstate inspection 2024-02-09 18:24:31 +01:00
bfredl e9510211f0 refactor(api): use arena for nvim_list_uis() 2024-02-09 18:24:21 +01:00
Will Hopkins 44ec4b5b18
refactor: rename FloatConfig to WinConfig #27397
`FloatConfig` is no longer used only for floats, so the name is counterintuitive.

Followup to #25550
2024-02-09 08:17:10 -08:00
bfredl e0e5b7f0ba refactor(api): make cstr_as_string accept "const char*"
In the context a String inside an Object/Dictionary etc is consumed,
it is considered to be read-only.
2024-02-09 15:11:21 +01:00
bfredl 52b6a9a93b
Merge pull request #27391 from bfredl/arenarock
refactor(api): refactor more api functions to use arena return
2024-02-08 18:54:00 +01:00
bfredl af5beac1bd refactor(api): refactor more api functions to use arena return
Currently having two separate memory strategies for API return values is
a bit unnecessary, and mostly a consequence of converting the hot spot
cases which needed it first. But there is really no downside to using
arena everywhere (which implies also directly using strings which are
allocated earlier or even statically, without copy).

There only restriction is we need to know the size of arrays in advance,
but this info can often be passed on from some earlier stage if it is
missing.

This collects some "small" cases. The more complex stuff will get a PR
each.
2024-02-08 14:40:34 +01:00
Jongwook Choi 800134ea5e refactor(treesitter): typing for Query, TSQuery, and TSQueryInfo
- `TSQuery`: userdata object for parsed query.

- `vim.treesitter.Query`: renamed from `Query`.
  - Add a new field `lang`.

- `TSQueryInfo`:
  - Move to `vim/treesitter/_meta.lua`, because C code owns it.
  - Correct typing for `patterns`, should be a map from `integer`
    (pattern_id) to `(integer|string)[][]` (list of predicates or
    directives).

- `vim.treesitter.QueryInfo` is added.
  - This currently has the same structure as `TSQueryInfo` (exported
    from C code).
  - Document the fields (see `TSQuery:inspect`).

- Add typing for `vim._ts_parse_query()`.
2024-02-08 12:40:16 +00:00
zeertzjq da3facb7ee vim-patch:9.1.0083: Redrawing can be improved when deleting lines with 'number'
Problem:  Redrawing can be improved when inserting/deleting lines with 'number'.
Solution: Only redraw the number column of lines below changed lines.
          Add a test as this wasn't previously tested.
          (zeertzjq)

closes: vim/vim#13985

ae07ebc04b
2024-02-08 19:20:07 +08:00
zeertzjq 1c2b9e8dd8 vim-patch:9.1.0082: Redrawing can be improved when deleting lines with '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

7ce34c9a94
2024-02-08 19:20:07 +08:00
nikolightsaber b162adbb7c
feat(api): pass 0 to nvim_get_chan_info for current channel (#27321)
Getting current channel info was kind of annoying via RPC. Two
functions had to be called:
1. `nvim_get_api_info` which returns `[channel_id, meta_data]`.
  - This results in `channel_id = api.nvim_get_api_info()[0]`.
  - Here the meta_data is sent but never used.
2. Finally call `nvim_get_chan_info(channel_id)`.

This commit reduces the need for `nvim_get_api_info` as passing 0
returns current channel info.
2024-02-08 18:59:31 +08:00
bfredl ca2635adf9 refactor(generators): style of generating and generated lua dispatch code 2024-02-08 11:14:01 +01:00
bfredl f9d81c43d2 refactor(api): use keydict and arena for more api return values
Implement api_keydict_to_dict as the complement to api_dict_to_keydict

Fix a conversion error when nvim_get_win_config gets called from lua,
where Float values "x" and "y" didn't get converted to lua numbers.
2024-02-08 11:14:01 +01:00
VanaIgr cca8a78ea2
perf: improve utf_char2cells() performance (#27353)
`utf_char2cells()` calls `utf_printable()` twice (sometimes indirectly,
through `vim_isprintc()`) for characters >= 128. The function can be
refactored to call to it only once.

`utf_printable()` uses binary search on ranges of unprintable characters
to determine if a given character is printable. Since there are only 9
ranges, and the first range contains only one character, binary search
can be replaced with SSE2 SIMD comparisons that check 8 ranges at a
time, and the first range is checked separately. SSE2 is enabled by
default in GCC, Clang and MSVC for x86-64.

Add 3-byte utf-8 to screenpos_spec benchmarks.
2024-02-07 15:03:45 +08:00
zeertzjq 6725565258
fix(event-loop): process input before events (#27358)
Problem:
When nvim_input is followed immediately by non-fast events on RPC, both
events and input are available after the polling done by the os_inchar()
in state_enter(), but state_enter() then chooses to process events even
if input is available, which is inconsistent with state_handle_k_event()
that stops processing events once input is available.

Solution:
Also check for available input after the os_inchar() in state_enter().
2024-02-07 12:11:22 +08:00
zeertzjq 0db6946b39
fix(column): handle w_redr_statuscol at end filler lines (#27365)
There doesn't seem to be an easy solution that doesn't involve a goto.
Also remove duplicate assignment in win_line().
2024-02-06 23:01:44 +08:00
zeertzjq 7fa84f32e7
vim-patch:9.1.0079: LineNrAbove/Below highlighting wrong on wrapped lines (#27363)
Problem:  LineNrAbove and LineNrBelow background wrong on wrapped lines.
Solution: Update number column also for wrapped part of a line.
          (zeertzjq)

closes: vim/vim#13974

ebfd856cfd

Cherry-pick test_number.vim changes from patch 9.0.0626.
2024-02-06 20:18:23 +08:00
dundargoc 63b810c9d8
docs: small fixes (#27213)
Co-authored-by: Matthieu Coudron <886074+teto@users.noreply.github.com>
2024-02-06 19:30:02 +08:00
zeertzjq a945a31e76
vim-patch:9.1.0077: Unnecessary call to redraw_for_cursorline() in nv_mousescroll() (#27359)
Problem:  The call to redraw_for_cursorline() in nv_mousescroll() is
          unnecessary because redraw_for_cursorline() only sets redraw
          type to UPD_VALID, and all code paths in do_mousescroll()
          already set redraw type to at least UPD_VALID.
Solution: Remove call to redraw_for_cursorline() in nv_mousescroll().
          (zeertzjq)

closes: vim/vim#13979

3f1b5312e0
2024-02-06 18:05:06 +08:00
Fred Sundvik a090d43d61 fix: splitting of big UI messages
Determine the needed buffer space first, instead of trying to revert the
effect of prepare_call if message does not fit. The previous code did
not revert the full state, which caused corrupted messages to be sent.
So, rather than trying to fix all of that, with fragile and hard to read
code as a result, the code is now much more simple, although slightly
slower.
2024-02-06 03:16:30 +02:00
Sean Dewar b3bda2f043
fix(tui): `space_buf` overflow when clearing screen (#27352)
Problem: `tui->space_buf` may be smaller than the width of the TUI or widest
grid, causing an overflow when calling `tui_grid_clear` if `print_spaces` is
called from `clear_region` (clears the TUI's screen since #23428).

Solution: resize `space_buf` to be wide enough to fit the TUI or widest grid.

Didn't bother shrinking the allocation if the max widths decrease.
2024-02-06 01:13:35 +00:00
Fred Sundvik d6483793e1 fix: buffer overrun in lmpack_session_receive
The offset was not taken into account when calculating the remaining buffer size.
2024-02-06 01:07:54 +02:00
zeertzjq d184933cdc
fix(redraw): update Visual selection properly with splits (#27343) 2024-02-05 15:34:17 +08:00
zeertzjq 35ffe58ea4
fix(inccommand): update topline after moving cursor (#27341) 2024-02-05 12:13:21 +08:00
zeertzjq 18e62c1bdb
perf(redraw): only redraw Visual area when cursor has moved (#27340) 2024-02-05 11:08:52 +08:00
Raphael 21df0cdb88
vim-patch:9.1.0075: insert completion not correct when adding new leader (#27332)
Problem:  insert completion not correct when adding new leader
Solution: Reset compl_curr_match to compl_shown_match
          (glepnir)

closes: vim/vim#13957

cbb46b4398
2024-02-04 11:12:31 +08:00
zeertzjq 80d7e7e5bf vim-patch:9.1.0074: did_set_breakat() should be in optionstr.c
Problem:  did_set_breakat() should be in optionstr.c as 'breakat' is a
          string option.
Solution: Move did_set_breakat() to optionstr.c.
          (zeertzjq)

closes: vim/vim#13958

eac3fdcfa0
2024-02-04 06:46:15 +08:00
zeertzjq 60701f4fff vim-patch:9.1.0073: Looping over modifier_keys_table unnecessarily
Problem:  Looping over modifier_keys_table[] unnecessarily with only
          MOD_MASK_ALT or MOD_MASK_CMD, as modifier_keys_table[] only
          contains MOD_MASK_SHIFT and MOD_MASK_CTRL, and the loop won't
          do anything.
Solution: Remove MOD_MASK_ALT and MOD_MASK_CMD from the condition.
          (zeertzjq)

closes: vim/vim#13963

0c989e4a3a
2024-02-04 06:46:09 +08:00
zeertzjq c559ab0ae6
feat: update unicode tables (#27317) 2024-02-04 06:28:51 +08:00
Raphael 51702e0aea
refactor(strcase_save): optimize memory allocation (#27319)
Problem: Double xmalloc usage led to excess memory allocations.
Solution: Switch to xrealloc to adjust memory as needed, minimizing allocations.
2024-02-03 15:29:05 +08:00
zeertzjq 6709f7f8f1
fix(keycodes): simplify S- properly when D- is present (#27316) 2024-02-03 11:05:38 +08:00
zeertzjq 9ab9cde2ca
vim-patch:partial:9.0.1196: code is indented more than necessary (#27315)
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes vim/vim#11813)

e857598896

Skip list_alloc_with_items().

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-02-03 10:22:11 +08:00
zeertzjq 1f40b4e222
vim-patch:9.0.1105: code is indented too much (#27314)
Problem:    Code is indented too much.
Solution:   Use an early return. (Yegappan Lakshmanan, closes vim/vim#11756)

87c1cbbe98

Omit free_eval_tofree_later(): Vim9 script only.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-02-03 09:42:04 +08:00
zeertzjq be1d09c427
fix(drawline): missing NUL termination when drawing TAB (#27307) 2024-02-02 22:31:57 +08:00
zeertzjq e98decf9a6
feat(quickfix): support -q - to read 'errorfile' from stdin (#27303)
Note that this only works when stdin is a pipe.
2024-02-02 21:17:37 +08:00
luukvbaal 4a1ad676ce
feat(ex_cmds): no error on :lua with {range} and {code} (#27290)
Problem:  Erroring when both {range} and {code} are supplied to
          :lua is inconvenient and may break mappings.
Solution: Don't error, ignore {range} and execute {code} when both
          are supplied.
2024-02-02 13:14:10 +08:00
bfredl 05fd70f19b
Merge pull request #27122 from luukvbaal/signcol
fix(column): clear "b_signcols" before moving saved marks
2024-02-01 18:52:12 +01:00
dundargoc 4c91194611 build: various fixes
- Consistently use the variable CMAKE_BUILD_TYPE to select build type.
- Remove broken `doc_html` target.
- Remove swap files created by oldtest when cleaning.
- Only rerun `lintdoc` if any documentation files has changed.
2024-02-01 12:06:55 +01:00
zeertzjq cc197d04fc
refactor(api): remove some unnecessary HAS_KEY() (#27283)
Since keydicts are already zero-initialized, HAS_KEY() isn't needed if
the zero-initialized value can satisfy some other condition.
2024-02-01 18:05:06 +08:00
Will Hopkins 6bba4beced
feat(api): make nvim_open_win support non-floating windows (#25550)
Adds support to `nvim_open_win` and `nvim_win_set_config` for creating
and manipulating split (non-floating) windows.
2024-02-01 11:43:35 +08:00
zeertzjq 8fa67fdae5
vim-patch:8.2.0085: dead code in builtin functions (#27281)
Problem:    Dead code in builtin functions.
Solution:   Clean up the code.

3d8a513b46

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-02-01 09:39:48 +08:00
zeertzjq 0a8e66898d
build: update builtin terminfo (#27272)
- Update to ncurses 6.4.20230520
- Disable smglp and smgrp for vtpcon and conemu
- Add xterm+sl to vtpcon, fix #26880
2024-01-31 21:45:30 +08:00
zeertzjq 9f15a18fa5
fix(statusline): missing offset when showing 'keymap' (#27270) 2024-01-31 08:48:52 +08:00
zeertzjq 4ffc20c951
fix(lua): avoid internal error when :luado deletes lines (#27262) 2024-01-30 08:09:25 +08:00
zeertzjq a2070ba877
vim-patch:9.1.0065: Segfault with CompleteChanged autocommand (#27261)
Problem:  Segfault with CompleteChanged autocommand
          (markonm )
Solution: Test match->cp_prev for being NULL before accessing it

closes: vim/vim#13929

fef6630166

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-01-30 07:34:37 +08:00
Will Hopkins ca9f6f5694
feat(api): add nvim_tabpage_set_win (#27222)
Allows setting the current window of a non-current tabpage
without switching tabpages.
2024-01-29 15:18:33 +08:00
Gregory Anders 15e77a56b7
feat(extmarks): subpriorities (relative to declaration order) (#27131)
The "priority" field of extmarks can be used to set priorities of
extmarks which dictates which highlight group a range will actually have
when there are multiple extmarks applied. However, when multiple
extmarks have the same priority, the only way to enforce an actual
priority is through the order in which the extmarks are set.

It is not always possible or desirable to set extmarks in a specific
order, however, so we add a new "subpriority" field that explicitly
enforces the ordering of extmarks that have the same priority.

For now this will be used only to enforce priority of treesitter
highlights. A single node in a treesitter tree may match multiple
captures, in which case that node will have multiple extmarks set. The
order in which captures are returned from the treesitter API is not
_necessarily_ in the same order they are defined in a query file, so we
use the new subpriority field to force that ordering.

For now subpriorites are not documented and are not meant to be used by
external code, and it only applies to ephemeral extmarks. We indicate
the "private" nature of subpriorities by prefixing the field name with
an "_".
2024-01-28 21:13:58 -06:00