0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

19161 Commits

Author SHA1 Message Date
Sean Dewar
4bb505e28c
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: #14142

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-05 20:39:07 +01:00
Ivan Pešić
e1051924c7
translation(sr): Update Serbian messages (#14143)
* translation(sr): Update Serbian messages
* Update serbian.nsi
* Update gvim.nsi

Add serbian language to the installer

Signed-off-by: Ivan Pešić <27575106+eevan78@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-05 20:34:00 +01:00
Sean Dewar
5131f224da
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: #14140

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-04 19:09:26 +01:00
Yegappan Lakshmanan
d3eae7bc11
patch 9.1.0148: Vim9: can't call internal methods with objects
Problem:  Vim9: can't call internal methods with objects
Solution: Add support for empty(), len() and string() function
          calls for objects (Yegappan Lakshmanan)

closes: #14129

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-03 16:34:51 +01:00
Colin Kennedy
2157035637
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:  #6445
closes: #13903

Signed-off-by: Colin Kennedy <colinvfx@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-03 16:16:47 +01:00
zeertzjq
c27fcf4857
patch 9.1.0146: v:echospace wrong with invalid value of 'showcmdloc'
Problem:  v:echospace wrong after setting invalid value to 'showcmdloc'.
Solution: Only call comp_col() if value is valid.
          (zeertzjq)

closes: #14119

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-01 23:03:16 +01:00
Sam-programs
062141b1a7
patch 9.1.0145: v:echospace not correct when 'showcmdloc' != last
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: #14108

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Sam-programs <130783534+Sam-programs@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-29 17:40:29 +01:00
Yegappan Lakshmanan
4d55c54e30
patch 9.1.0144: getregion() needs more tests
Problem:  getregion() needs more tests
Solution: Run the getregion() test in both the legacy and Vim9 contexts
          (Yegappan Lakshmanan)

closes: #14114

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-29 17:30:43 +01:00
Christian Brabandt
55f8bba73b
patch 9.1.0143: [security]: autocmd causes use-after-free in set_curbuf()
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: #13839
closes: #14104

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28 23:32:00 +01:00
Shougo Matsushita
19b718828d
patch 9.1.0142: getregion() can be improved
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: #14090

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28 22:49:03 +01:00
zeertzjq
4e141c66b9
patch 9.1.0141: Put in Visual mode wrong if it replaces fold marker
Problem:  Put in Visual mode wrong if it replaces fold marker.
Solution: Temporarily disable folding during put in Visual mode.
          (zeertzjq)

fixes: #14097
closes: #14100

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28 21:49:51 +01:00
Ivan Pešić
97a35ae356
translation(sr): Update Serbian translation (#14107)
Signed-off-by: Ivan Pešić <27575106+eevan78@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28 21:41:27 +01:00
Antonio Giovanni Colombo
0c98a71236
translation(it): Update Italian translation
Signed-off-by: Antonio Giovanni Colombo <azc100@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-27 22:41:22 +01:00
Dylan Thacker-Smith
da0c9137d1
patch 9.1.0140: cursor on wrong row after 1 char 'below' virtual text when EOL is shown
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: #11959
related: #12028
closes: #14096

Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-27 20:25:10 +01:00
Erik S. V. Jansson
2f02638aa8
patch 9.1.0139: MS-Windows: ligatures map cleared on startup
Problem:  MS-Windows: ligatures map cleared on startup
Solution: Don't clear the ligatures_map, if the guiligatures
          option has already been set (Erik S. V. Jansson)

If guiligatures is set from a .vimrc it's possible
that it will be cleared on start-up (e.g. in Win32
that's what happens).

So don't clear the ligatures map if gui_set_ligatures()
has already been called (e.g. after setting 'ligatures'
from .vimrc)

closes: #14094

Signed-off-by: Erik S. V. Jansson <caffeineviking@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-26 22:23:05 +01:00
John Marriott
02d7a6c6cf
patch 9.1.0138: too many STRLEN calls when getting a memline
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: #14052

Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-26 21:25:03 +01:00
zeertzjq
ff2b79d239
patch 9.1.0137: <Del> in cmdline mode doesn't delete composing chars
Problem:  <Del> in cmdline mode doesn't delete composing chars
Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq)

closes: #14095

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-26 20:38:36 +01:00
Yegappan Lakshmanan
a2ebb6e917
patch 9.1.0136: Vim9: need more test for exists()
methods

Problem:  Vim9: need more test for exists()
Solution: Add test for exists() with class/objct variables and methods
          (Yegappan Lakshmanan)

closes: #14088

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-25 08:40:10 +01:00
zeertzjq
cd3a13e774
patch 9.1.0135: Insufficient testing for 'delcombine'
Problem:  Insufficient testing for 'delcombine'.
Solution: Add test for both Normal and Insert modes without Arabic.
          (zeertzjq)

closes: #14086

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 16:51:32 +01:00
Christian Brabandt
6a46c19b25
patch 9.1.0134: CI: Test_term_gettitle() is flaky on MacOS 14
Problem:  Test_term_gettitle() is flaky on MacOS 14 and Github runners
Solution: Skip the test on Github CI

closes: #14085

It fails with this: '^\\[No Name\\] - VIM\\d*$' does not match 'e] - VIM'
It is not clear why term_gettitle() only get's the last part of the
expected title (perhaps there is a Carriage return in there or the
terminal window is too small?)

So let's just skip this test for now.

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 15:58:04 +01:00
Erik S. V. Jansson
8b1e749ca6
patch 9.1.0133: MS-Windows: ligatures not rendering correctly
Problem:  font ligatures don't render correctly in the Win32 GUI-version
          of gvim even when set rop=type:directx is used. Setting
          guiligatures also doesn't make any difference. This leads to
          broken font ligatures when the cursor passes through them. It
          does not recover from this, and they remain broken until you
          re-render the whole buffer (e.g. by using Ctrl+L).

Solution: the problem is that we only re-draw the current and previous
          character in gui_undraw_cursor() and only have the special case
          for GTK when it comes to rendering ligatures. So let's enable
          gui_adjust_undraw_cursor_for_ligatures() to also happen for
          Win32 GUI if guiligatures is setup correctly (all this does is
          expand the range of gui_undraw_cursor() with ligature characters).

related: #9181
related: #12901
closes: #14084

Signed-off-by: Erik S. V. Jansson <caffeineviking@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 14:26:52 +01:00
zeertzjq
048761bcd4
patch 9.1.0132: "C" doesn't include composing chars with 'virtualedit'
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: #14083

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 14:21:39 +01:00
Christian Brabandt
0dc0bff000
patch 9.1.0131: buffer-completion may not always find all matches
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 #13894
closes: #14082

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 14:17:33 +01:00
Sean Dewar
abf7030a5c
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)

closes: #14078

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 10:20:24 +01:00
Dylan Thacker-Smith
f548ae7b63
patch 9.1.0129: Fix truncation of text_wrap 'wrap' virt text after EOL list char
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: #12725
closes: #14079

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24 10:17:11 +01:00
Sean Dewar
2a65e73944
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)

Other potential causes of E565 from win_gotoid after v9.1.0119 should be
correct. Plugins can consider using win_execute() instead if they wish to
temporarily switch windows during textlock.

fixes: #14073
closes: #14074

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-22 19:53:33 +01:00
zeertzjq
5e3674b42d
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: #14075

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-22 19:51:34 +01:00
zeertzjq
421b597470
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: #14076

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Internal error when passing mark in another buffer to getregion()
2024-02-22 19:48:06 +01:00
Dylan Thacker-Smith
83925be1e6
patch 9.1.0125: unused init of text_prop_idxs in win_line()
Problem:  unused init of text_prop_idxs in win_line
Solution: Remove it, fix typo
          (Dylan Thacker-Smith)

Later use of text_prop_idxs treats it as empty, incrementing
text_props_active as new elements are added to this array, so remove
this unused conditional initialization when text_props_active is 0.

closes: #14063

Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 21:03:10 +01:00
Dylan Thacker-Smith
8055721c2d
patch 9.1.0124: display of below/right virtual text with non-virtual text overlap
Problem:  Virtual text with text_align 'right'/'below' wasn't being
          used when a non-virtual text property overlaps with the end of
          the line. This was because the non-virtual text property had a
          higher priority, preventing the virtual text from being used.
Solution: Fix the sorting of text properties so virtual text properties
          have a higher priority than non-virtual text properties.
          (Dylan Thacker-Smith)

related: #14063

Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 21:00:59 +01:00
GuyBrush
52ecc76c7f
patch 9.1.0123: MS-Windows: system() may deadlock
Problem:  MS-Windows: system() may deadlock when calling binaries that
          expect stdin
Solution: Ignore the SHELL_EXPAND flag
          (GuyBrush)

This happens on binaries that expect stdin. For example:

:echo system("xxd")

will cause a deadlock.

SHELL_EXPAND is a flag devoted to support the linux implementation of
the backtick-expansion mechanism.

On linux backtic-expansion relies in the function mch_expand_wildchars()
(os_unix.c) that delegates on each specific shell (bash, sh, csh, zsh)
the expansion. Basically it composes a shell command that does the
expansion and redirects the output to a file and call_shell() it. On
windows backtick-expansion is performed by Vim itself.

On linux SHELL_EXPAND modifies how mch_call_shell_fork() (os_unix.c)
works. This function:

- relies on posix fork() to spawn a child process to execute a
  external command.
- Child and parent process communicate using pipes (or pseudoterminal
  if available).
  User input (type ahead content) is processed in a loop only if
  !(SHELL_EXPAND || SHELL_COOKED).
  Though signals are used to detect Ctrl-C in all cases (the input
  loop is not necessary to interrupt the function).
  In the backtick-expansion the external command is the shell command
  that provides the expansion. For the child redirection:
  -  SHELL_EXPAND replaces stdin, stdout & stderr to /dev/null. This is
     why the shell command composed includes redirection (otherwise
     output would be lost).

  -  !SHELL_EXPAND replaces stdin, stdout & stderr with the parent
     created pipes (or pseudoterminal).
     Note that the use of SIGINT signal prevents mch_call_shell_fork()
     from hanging vim.

On Windows mch_system_piped() (os_win32.c) (which is only used when the
GUI is running) mimics mch_call_shell_fork() (os_unix.c).
Win32 lacks fork() and relies on CreateProcessW() and only has pipe
support (not pseudoterminal) which makes the implementation much
different.

But, the key idea is that windows lacks signals, the OS provides support
for console apps but gvim is not one. The only way of detecting a Ctrl-C
is actually processing user input (type ahead content). By ignoring the
user input under SHELL_EXPAND the function can hang gvim.

Ignoring SHELL_EXPAND flag has no consequence in Windows because as
mentioned above it is only meaningful in linux.

closes: #13988

Signed-off-by: GuyBrush <miguel.barro@live.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 20:16:38 +01:00
Maxim Kim
9ca335aad2
patch 9.1.0122: Some minor issues with the getregion() function
Problem:  Some minor issues with the getregion() function
Solution: Fix examples in the help, use OP_NOP op_type and MBLOCK
          as motion_type in f_getreg(), update vim syntax to
          for getregion() (Maxim Kim)

```
:xnoremap <CR>
\ <Cmd>echow getregion('v', '.', mode())<CR>
```
`echo` while in visual mode has no visible effect, thus people trying
example might be frustrated as it looks like nothing happens.

So the option is to change it to `echow` or `echom`.
With `echom` it is again has no visible effect but one can at least inspect `:messages`.
On the other hand `echow` showes selected text in a popup window.

```
Can also be used as a |method|: >
'.'->getregion("'a', 'v')
```

Here is the typo, which makes example invalid, should be `("'a", ...`

closes: #14064

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 19:53:02 +01:00
Sean Dewar
02fcae02a9
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)

Don't instead reset w_skipcol; that would lose the scroll position
within the line, which may be undesirable if the window is made wider
later.

Also include changes from the splitmove PR #14042 that I (in my infinite
Git wisdom) forgot to commit. This includes a change to
Test_window_split_no_room to ensure it doesn't fail for some screen
sizes.

Move Test_smoothscroll_in_zero_width_window to test_scroll_opt.vim, as
that file feels more appropriate.

closes: #14068

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 19:40:44 +01:00
Shougo Matsushita
3f905ab3c4
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: #13998
closes: #11579

Co-authored-by: =?UTF-8?q?Jakub=20=C5=81uczy=C5=84ski?= <doubleloop@o2.pl>
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21 00:02:45 +01:00
Sean Dewar
f865895c87
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).

closes: #14042

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20 22:05:10 +01:00
Sean Dewar
704966c254
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)

This also means we no longer must allocate.

related: #14042

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20 22:00:33 +01:00
Sean Dewar
96cc4aef3d
patch 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)

Likewise, before this patch, WinClosed was not fired anyway (even for :wincmd
H/J/K/L, which also didn't fire WinNew, but did still fire WinNewPre), despite
documentation saying windows are "closed". Note that :wincmd T actually indeed
works by creating a new window (and closing the old one), unlike the others.

This also fixes issues where WinNewPre is fired when split-moving while curwin
doesn't yet have a frame or entry in the window list, causing many things to not
work (it's not considered valid at that point). This was guaranteed when using
:wincmd H/J/K/L.

Because WinNewPre is no longer fired when split-moving, this makes restoring the
previous window layout on failure easier, as we can be sure that frames are not
resized from WinNewPre autocommands if win_split_ins fails. This allows us to
use a different strategy in the following commit.

--

In my opinion, this leaves questions about the current usefulness of WinNewPre.
A motivation described in #10635 states how creating a new window can steal room
from other windows, and how WinNewPre will be useful for detecting that, but
this is also true when inserting an existing window, which now doesn't fire it.
Maybe the autocommand should be changed to have a better name?

There are also other issues I found with the current implementation of WinNewPre
that need addressing:

- it allows switching windows and tabpages, which can cause incorrect windows to
  be split/moved, and big problems when switching tabpages.

- it fires before win_split_ins checks for room, before it makes any changes to
  window sizes or before it considers allocating a new window. This should be
  changed or documented.

I hope to address some of this stuff in a different PR, if possible.

related: #14038

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20 21:52:31 +01:00
Sean Dewar
0fd44a5ad8
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)

win_split_ins has no check for E36 when moving an existing window,
allowing for layouts with many overlapping zero-sized windows to be
created (which may also cause drawing issues with tablines and such).
f_win_splitmove also has some bugs.

So check for room and fix the issues in f_win_splitmove. Handle failure
in the two relevant win_split_ins callers by restoring the original
layout, and factor the common logic into win_splitmove.

Don't check for room when opening an autocommand window, as it's a
temporary window that's rarely interacted with or drawn anyhow, and is
rather important for some autocommands.

Issues fixed in f_win_splitmove:
- Error if splitting is disallowed.
- Fix heap-use-after-frees if autocommands fired from switching to "targetwin"
  close "wp" or "oldwin".
- Fix splitting the wrong window if autocommands fired from switching to
  "targetwin" switch to a different window.
- Ensure -1 is returned for all errors.

Also handle allocation failure a bit earlier in make_snapshot (callers,
except win_splitmove, don't really care if a snapshot can't be made, so
just ignore the return value).

Note: Test_smoothscroll_in_zero_width_window failed after these changes with
E36, as it was using the previous behaviour to create a zero-width window.
I've fixed the test such that it fails with UBSAN as expected when v9.0.1367 is
reverted (and simplified it too).

related: #14042

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20 20:35:41 +01:00
dkearns
ef387c062b
runtime(filetype): Modula-2 files with priority not detected (#14055)
Problem:  Modula-2 files with a specified priority are not detected.
Solution: Match the priority syntax in module header lines when
          performing heuristic content detection.

Disable the :defcompile debug line.  This was accidentally left enabled
in commit 68a8947.

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-19 20:58:30 +01:00
zeertzjq
c86bff1771
patch 9.1.0115: Using freed memory with full tag stack and user data
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: #14053

Co-authored-by: Konstantin Khlebnikov koct9i@gmail.com
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Konstantin Khlebnikov koct9i@gmail.com
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-18 18:57:07 +01:00
zeertzjq
fcaed6a70f
patch 9.1.0114: Setting some options may change curswant
Problem:  Setting some options changes curswant unnecessarily.
Solution: Add a P_HLONLY flag that prevents changing curswant.
          (zeertzjq)

closes: #14044

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-18 09:33:54 +01:00
Christian Brabandt
9071ed8107
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: #13928

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-15 20:17:37 +01:00
Christian Brabandt
f0d3d4a426
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: #13905
closes: #13928

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-15 20:15:04 +01:00
Brandon Maier
d00fb4b3a2
patch 9.1.0111: filetype: no support for bats files
The '*.bats' file type is for Bash Automated Testing System (BATS)
scripts. BATS scripts are Bash with a special '@test' extension but they
otherwise work with Vim's bash filetype.

See https://github.com/bats-core/bats-core

closes: #14039

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-15 00:17:05 +01:00
Brandon Maier
5f20f050ef
patch 9.1.0110: filetype: add 'Config.in' filetype detection
The 'Config.in' file type is for Buildroot configuration files.
Buildroot Config.in files use the same Kconfig backend as the Linux
kernel's Kconfig files.

Buildroot also has other filename variants that follow "Config.in.*",
they are used to distinguish multiple Config.in files in the same
directory.

See https://buildroot.org/downloads/manual/manual.html#_literal_config_in_literal_file

closes: #14038

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-14 22:30:06 +01:00
Brandon Maier
cf1d65e060
patch 9.1.0109: filetype: no support for its files
Problem:  filetype: no support for its files
Solution: Add detection for *.its files as dts file type
          (Brandon Maier)

The '*.its' file type is for U-Boot Flattened Image Trees (FIT) which
use the flattened devicetree format.

See https://github.com/u-boot/u-boot/blob/master/doc/usage/fit/source_file_format.rst#terminology

closes: #14037

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-14 21:33:40 +01:00
Markus Schneider-Pargmann
b1700fb33f
patch 9.1.0108: filetype: no support for dtso files
Problem:  filetype: no support for dtso files
Solution: Add detection for *.dtso files as dts file type
          (Markus Schneider-Pargmann)

*.dtso files are devicetree overlay files which have the same syntax as dts or dtsi files.

closes: #14026

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-14 20:44:28 +01:00
Yee Cheng Chin
49f2ba6d41
patch 9.1.0107: CI: Fix MacOS-14 tests
Problem:  CI: Fix MacOS-14 tests (after 9.1.0070)
Solution: Re-enable sound tests by granting Mic access,
          disable Test_diff_screen because of buggy MacOS diff
          (non GNU version), re-enable Test_term_gettitle()
          (Yee Cheng Chin)

macos-14 runner was turned on in #13943, but it had to turn off a few
tests in order for CI to run. Re-enable them and fix the underlying
issues.

* `Test_diff_screen`: The test failure is due to a bug in Apple's diff
  utility. Apple introduced a new diff tool based on FreeBSD in macOS 13
  and it has buggy behaviors when using unified diff (`-U0`) and the
  diff is on the first line of the file. Simply disable this test for
  now if we detect Apple diff (instead of the old GNU diff). Can
  re-enable this in the future if Apple fixes the issue.
* `Test_play_event` / `Test_play_silent`: GitHub Actions currently has
  an issue with playing sound in CI in macos-14 runners. It for some
  reason triggers a microphone permission dialog popup which blocks the
  CI action (see https://github.com/actions/runner-images/issues/9330).
  To fix this, add a temporary step in macos-14 to manually allow
  microphone permissions in the runner.
* `Test_term_gettitle`: I could not reproduce the failure, so I just
  turned it on and it seems to run just fine. Maybe it's a timing issue
  and whatnot but either way that should be fixed when we can reproduce
  the issue.

closes: #14032

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-14 20:34:58 +01:00
Maxim Kim
34e4a05d02
patch 9.1.0106: Visual highlight hard to read with 'termguicolors'
Problem:  Visual highlight hard to read with 'termguicolors'
          (Maxim Kim)
Solution: Set Visual GUI foreground to black (with background=light)
          and lightgrey (with background=dark)
          (Maxim Kim)

fixes: #14024
closes: #14025

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-14 20:28:17 +01:00
zeertzjq
e71022082d
patch 9.1.0105: Style: typos found
Problem:  Style: typos found
Solution: correct them
          (zeertzjq)

closes: #14023

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-13 20:32:04 +01:00