Mark Woods [Sun, 22 Jun 2025 18:16:29 +0000 (20:16 +0200)]
runtime(comment): add <Plug>-mappings
vim9script <expr> mappings relying on imports cannot be evaluated
outside of the script file with the imports, so do not work with plugins
like vim-which-key, which evaluates <expr> mappings to apply them.
Using <Plug> mappings is one way to address this, and has the added
benefit of reading like a description for users finding the mappings.
fixes: #17523
closes: #17563
Signed-off-by: Mark Woods <mwoods.online.ie@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Mark Woods [Sun, 22 Jun 2025 18:12:16 +0000 (20:12 +0200)]
runtime(openPlugin): add <Plug>-mappings
vim9script <scriptcmd> mappings relying on imports cannot be evaluated
outside of the script file with the imports, so do not work with plugins
like vim-which-key, which applies the mappings using feedkeys().
Using <Plug> mappings is one way to address this, and has the added
benefit of reading like a description for users finding the mappings.
related: #17563
Signed-off-by: Mark Woods <mwoods.online.ie@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Damien Lejay [Sun, 22 Jun 2025 17:39:04 +0000 (19:39 +0200)]
runtime(tutor): Make all tutor files utf-8 only
In this commit, all legacy encodings for tutor files are removed.
* All the tutor files `tutor1.xx` and `tutor2.xx` are now `utf-8`
* All `README.xx.txt` files are now `utf-8`
* All makefiles are removed, as they are no longer needed
* The `tutor.vim` script is simplified
* The `README` indicates `utf-8` as a requirement
* update vimtutor.bat file
In 2025, there is no realistic scenario where a beginner starts the Vim
9.1 tutor on a machine that lacks UTF-8 support.
This change will ease the maintenance of the tutor files. Cf #17562 for
an example.
Doug Kearns [Sun, 22 Jun 2025 16:47:49 +0000 (18:47 +0200)]
runtime(vim): Update base-syntax, match bare mark ranges
Remove unmatchable :normal {mark,register} matches. The arg to :normal
is now handled separately and contained marks and registers are no
longer matched.
closes: #17571
Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
patch 9.1.1473: inconsistent range arg for :diffget/diffput
Problem: inconsistent range arg for :diffget/diffput
Solution: fix the range specification, place the cursor for :diffput and
:diffget consistently on the last line (Yee Cheng Chin)
Previously, `:<range>diffget` only allowed using 1 or above in the range
value, making it impossible to use the command for a diff block at the
beginning of the file. Fix the range specification so the user can now
use 0 to specify the space before the first line. This allows
`:0,$+1diffget` to work to retrieve all the changes from the other file
instead of missing the first diff block. Also do this for `:diffput`.
Also, make `:diffput` work more similar to `:diffget`. Make it so that
if the cursor is on the last line and a new line is inserted in the
other file, doing `:diffput` will select that diff block below the line,
just like `:diffget` would.
Also clean up the logic a little bit for edge cases and for handling
line matched diff blocks better.
closes: #17579
Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: if_python: PySequence_Fast_{GET_SIZE,GET_ITEM} removed with
python3.14 in stable ABI
Solution: use PySequence_{Size,GetItem} instead (Zdenek Dohnal)
Python 3.14 removed those two functions from stable API because of
reasoning these function shouldn't be part of stable API at the first
place.
Moving to PySequence_GetSize and PySequence_GetItem fixes the build
failure when Vim is built with dynamic Python and stable API for Python
3.8.
closes: #17575
Signed-off-by: Zdenek Dohnal <zdohnal@redhat.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
patch 9.1.1469: potential buffer-underflow with invalid hl_id
Problem: potential buffer-underflow with invalid hl_id (mugitya03)
Solution: assert that the return-code of syn_get_final_id() if > 0
As a safety check, syn_get_final_id() may return zero when either the
provided hl_id is zero or larger than expected.
However, many callers of syn_get_final_id() do not check that the return
value is larger than zero but re-use the returned highlight id directly
like this:
hl_id = syn_get_final_id(hl_id);
sgp = &HL_TABLE()[hl_id - 1]; // index is ID minus one
in which case, this would cause a buffer underrun and an access violation.
Let's use assert(hl_id > 0); to make sure that hl_id is larger than
zero.
Note to myself: I'll need to compile releases builds using -DNDEBUG once
a new release will be made
Riley Bruins [Wed, 18 Jun 2025 16:23:05 +0000 (18:23 +0200)]
patch 9.1.1468: filetype: bright(er)script files are not recognized
Problem: filetype: bright(er)script files are not recognized
Solution: detect *.bs files as brighterscript filetype and *.brs as
brightscript filetype, include filetype plugins (Riley Bruins)
closes: #17566
Signed-off-by: Riley Bruins <ribru17@hotmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
John Marriott [Wed, 18 Jun 2025 16:15:31 +0000 (18:15 +0200)]
patch 9.1.1467: too many strlen() calls
Problem: too many strlen() calls
Solution: Change expand_env() to return string length
(John Marriott)
This commit does the following changes:
- In expand_env_esc():
- return the length of the returned dst string.
- refactor to remove some calls to STRLEN() and STRCAT()
- add check for out-of-memory condition.
- Change call sites in various source files to use the return value
closes: #17561
Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
Eisuke Kawashima [Tue, 17 Jun 2025 18:30:52 +0000 (20:30 +0200)]
patch 9.1.1466: filetype: not all lex files are recognized
Problem: filetype: not all lex files are recognized
Solution: detect *.ll as lex, llvm or lifelines filetype, depending on
the content (Eisuke Kawashima)
closes: #17560
Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime(vimtutor): vimtutor throws Access Denied Error on MS-Windows
Problem: MS-Windows: vimtutor throws Access Denied Error
Solution: switch the order of redirects. First redirect stdout, than
stderr to stdout, Try to access $TEMP before current directory
(which is usually c:\Program Files\vim\vim91\ and not writable
for normal users)
Hirohito Higashi [Mon, 16 Jun 2025 17:39:24 +0000 (19:39 +0200)]
patch 9.1.1461: tabpanel: tabpanel vanishes with popup menu
Problem: tabpanel: tabpanel vanishes with popup menu
Solution: remove pum-related test in tabpanel_leftcol(), refactor a few
related functions (Hirohito Higashi)
This commit does the following:
- Delete unnecessary pum-related checks in the tabpanel_leftcol()
function
- remove pum-related check in tabpanel_leftcol()
- The argument of the TPL_LCOL() macro has been deleted.
- The argument of the tabpanel_leftcol() function has been changed
to void
- The return type of the `win_comp_pos()` function has been changed to
void
closes: #17549
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
John Marriott [Sun, 15 Jun 2025 14:50:38 +0000 (16:50 +0200)]
patch 9.1.1460: MS-Windows: too many strlen() calls in os_win32.c
Problem: MS-Windows: too many strlen() calls in os_win32.c
Solution: refactor code and remove calls to strlen() and wcscat()
(John Marriott)
This commit does the following changes:
- in mch_get_exe_name():
- refactor to remove call to wcsrchr().
- refactor to replace calls to wcscat() with wcscpy().
- move variables closer to where they are used.
- change test to make sure that concatenating path and exe_pathw
will fit inside the environment string (taking into account that
path may be NULL).
- in executable_exists():
- add namelen argument.
- use string_T to store some strings.
- refactor to remove calls to STRLEN() (via STRCAT()).
- in mch_getperm():
- move call to mch_stat() into return statement and drop unneeded
variable.
- in mch_wrename():
- refactor to use wide character comparisons.
- some cosmetic code styling changes (removing extraneous spaces, etc).
closes: 17542
Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
patch 9.1.1459: xxd: coloring output is inefficient
Problem: xxd prints color escape sequences for every octet
even if the color doesn't change
Solution: use separate arrays for colors and text and only
print escape sequences when the color changes
(Emanuel Krollmann)
fixes: #15122
closes: #17535
Signed-off-by: Emanuel Krollmann <E.Krollmann@protonmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Gary Johnson [Thu, 12 Jun 2025 19:15:07 +0000 (21:15 +0200)]
runtime(doc): remove an obsolete item from todo.txt
I cannot reproduce this defect. The replication instructions refer to
Mercurial version numbers and I no longer use Mercurial for my Vim
source. I tried comparing various Git versions of the example file,
src/if_cscope.c, and still couldn't reproduce the defect. Also, I use
Vim's diff mode a lot and haven't seen such a problem in a long time.
I am confident that it has been fixed.
Therefore, the item should be removed from todo.txt.
closes: #17534
Signed-off-by: Gary Johnson <garyjohn@spocom.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
jinyaoguo [Wed, 11 Jun 2025 19:30:01 +0000 (21:30 +0200)]
patch 9.1.1455: Haiku: dailog objects created with no reference
Problem: Haiku: dailog objects created with no reference
Solution: delete the objects before returning (jinyaoguo)
In the functions gui_mch_dialog() and gui_mch_font_dialog(), Dialog
objects are created but never escape the function scope. The call to
dialog->Go() only returns a boolean value and does not retain any
reference to the Dialog object itself, which may lead to potential
memory leak.
Fix this by deleting the object after using it.
closes: #17501
Signed-off-by: jinyaoguo <guo846@purdue.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
Ilya Grigoriev [Wed, 11 Jun 2025 19:07:35 +0000 (21:07 +0200)]
runtime(doc): add more pointers to 'completeopt'
Before this commit, I had trouble finding information about configuring
the insert mode completion. In particular, it was not clear that the
'wildopt' config that I already had in my vimrc does not apply here.
Also, `insert.txt` barely mentioned 'completeopt' except when
describing popups (I was more interested in bash-like behavior
where the unique prefix of all completions is completed first).
I'm hoping these edits will make the relevant docs easier to find.
closes: #17515
Signed-off-by: Ilya Grigoriev <ilyagr@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Doug Kearns [Tue, 10 Jun 2025 19:15:22 +0000 (21:15 +0200)]
runtime(filetype): Use s:StarSetf for all patterns ending in *
Problem: Some filetype autocmds with patterns ending in * do not skip
filenames matching g:ignored_patterns.
Solution: Move these autocmds to the appropriate section and call
s:StarSetf() to set the filetype.
- Affected filetypes: dosini, execline, foam, messages, nginx, tmux.
- Convert foam filetype patterns to use wildcard matching.
closes: #17422
Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
zeertzjq [Tue, 10 Jun 2025 18:31:44 +0000 (20:31 +0200)]
patch 9.1.1450: Session has wrong arglist with :tcd and :arglocal
Problem: Session has wrong arglist with :tcd and :arglocal.
Solution: Also use absolute path for :argadd when there is tabpage-local
directory (zeertzjq).
related: neovim/neovim#34405
closes: #17503
Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Girish Palya [Mon, 9 Jun 2025 18:43:03 +0000 (20:43 +0200)]
patch 9.1.1445: negative matchfuzzy scores although there is a match
Problem: negative matchfuzzy scores although there is a match
(Maxim Kim)
Solution: reset the score if a match has been found but the score is
negative (Girish Palya)
The fuzzy algorithm may miss some matches in long strings due to recursion
limits. As a result, the score can end up negative even when matches exist.
In such cases, reset the score to ensure it is non-negative.
fixes: ##17449
closes: #17469
Signed-off-by: Girish Palya <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
jinyaoguo [Mon, 9 Jun 2025 18:31:17 +0000 (20:31 +0200)]
patch 9.1.1443: potential buffer underflow in insertchar()
Problem: potential buffer underflow in insertchar()
Solution: verify that end_len is larger than zero
(jinyaoguo)
When parsing the end-comment leader, end_len can be zero if
copy_option_part() writes no characters. The existing check
unconditionally accessed lead_end[end_len-1], causing potential
underflow when end_len == 0.
This change adds an end_len > 0 guard to ensure we only index lead_end
if there is at least one character.
closes: #17476
Signed-off-by: jinyaoguo <guo846@purdue.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
Gary Johnson [Mon, 9 Jun 2025 18:19:35 +0000 (20:19 +0200)]
patch 9.1.1442: tests: Test_diff_fold_redraw() is insufficient
Problem: tests: Test_diff_fold_redraw() is insufficient
(after v9.1.1439, Christ van Willegen)
Solution: improve the test (Gary Johnson)
The original Test_diff_fold_redraw() function, added 2025-06-08 at patch
9.1.1439, had a bug and didn't do a very good job of testing the fold
behavior. This new version is simpler and more thorough.
The bug was that it checked the fold state of one window twice instead
of checking both windows.
closes: #17492
Signed-off-by: Gary Johnson <garyjohn@spocom.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Girish Palya [Sun, 8 Jun 2025 14:20:06 +0000 (16:20 +0200)]
patch 9.1.1441: completion: code can be improved
Problem: completion: code can be improved
Solution: remove reposition_match() and use mergesort_list(),
for fuzzy completion, sort by fuzzy score immediately after
setting a new leader (Girish Palya)
John Marriott [Sun, 8 Jun 2025 14:05:53 +0000 (16:05 +0200)]
patch 9.1.1440: too many strlen() calls in os_win32.c
Problem: too many strlen() calls in os_win32.c
Solution: refactor code and remove calls to strlen()
(John Marriott)
The following changes have been made:
- In mch_init_g():
- refactor to remove calls to STRLEN().
- use vim_strnsave() instead of vim_strsave().
- set a flag if vimrun_path is stored in allocated memory so it can be
freed at exit.
- In mch_exit() free vimrun_path if it was stored in allocated memory.
- In fname_case() make a small optimisation by measuring the length of
name only if needed.
- In copy_extattr() make a small optimisation by replacing call to
STRCAT() with STRCPY().
closes: #17462
Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
Gary Johnson [Sun, 8 Jun 2025 14:00:06 +0000 (16:00 +0200)]
patch 9.1.1439: Last diff folds not merged
Problem: Last diff folds not merged (after v8.1.1922)
Solution: loop over all windows in the current tabpage and update all
folds (Gary Johnson)
This commit fixes a bug where the last two folds of a diff are not
merged when the last difference between the two diff'd buffers is
resolved.
Normally, when two buffers are diff'd, folding is used to show only the
text that differs and to hide the text that is the same between the two
buffers. When a difference is resolved by making a block of text the
same in both buffers, the folds are updated to merge that block with the
folds above and below it into one closed fold.
That updating of the folds did not occur when the block of text was the
last diff block in the buffers.
The bug was introduced by this patch on August 24, 2019:
patch 8.1.1922: in diff mode global operations can be very slow
Problem: In diff mode global operations can be very slow.
Solution: Do not call diff_redraw() many times, call it once when
redrawing. And also don't update folds multiple times.
Unfortunately, folds were then not updated often enough.
The problem was fixed by adding a short loop to the ex_diffgetput()
function in diff.c to update all the folds in the current tab when the
last difference is removed.
A test for this was added to test_diffmode.vim. Two of the reference
screen dumps for another test in that file,
Test_diffget_diffput_linematch(), had to be changed to have all the
folds closed rather than to have the last diff block remain open.
closes: #17457
Signed-off-by: Gary Johnson <garyjohn@spocom.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_breakindent_list_split() fails
(Phạm Bình An)
Solution: Always reset "&columns" and "&lines" for GUI builds
(Aliaksei Budavei)
Ensure that "&columns" and "&lines" are always set to their
default values before calling "SetUp()", if any, for EACH
test run by a GUI build to avoid yet-to-be-run tests from
inheriting possibly changed values (after window resizing)
and leading to broken assumptions about available estate and
occasional test failures.
fixes: #17453
closes: #17447
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime(vim): vimHLGroup is not highlighted correctly
Problem: vimHLGroup is not highlighted in "hi def link"
and "hi clear" commands
Solution: highlight vimHLGroup similarly to vimGroup
(Eisuke Kawashima)
Phạm Bình An [Thu, 5 Jun 2025 19:21:35 +0000 (21:21 +0200)]
runtime(typescript): remove Fixedgq() function from indent script
Problem:
1. The `Fixedgq()` function is broken (see #17412)
2. The `'formatexpr'` for Typescript is not documented, which causes
confusion to users when they try to set `'formatprg'`, since
`'formatexpr'` always takes precedence over `'formatprg'`. See also
https://github.com/HerringtonDarkholme/yats.vim/issues/209
3. Typescript already has a very good and popular formatter called
`prettier`, that can be easily integrated to Vim via `'formatprg'`
(see #16989). I don't think there are any good reasons to reinvent a
half-baked version in Vim.
Solution: Remove the Fixedgq() 'formatexpr' function.
fixes: #17412
closes: #17452
Signed-off-by: Phạm Bình An <phambinhanctb2004@gmail.com> Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Girish Palya [Thu, 5 Jun 2025 19:04:29 +0000 (21:04 +0200)]
patch 9.1.1435: completion: various flaws in fuzzy completion
Problem: completion: various flaws in fuzzy completion
Solution: fix the issues (Girish Palya)
- Remove the brittle `qsort()` on `compl_match_array`.
- Add a stable, non-recursive `mergesort` for the internal doubly
linked list of matches.
- The sort now happens directly on the internal representation (`compl_T`),
preserving sync with external structures and making sorting stable.
- Update fuzzy match logic to enforce `max_matches` limits after
sorting.
- Remove `trim_compl_match_array()`, which is no longer necessary.
- Fixe test failures by correctly setting `selected` index and
maintaining match consistency.
- Introduce `mergesort_list()` in `misc2.c`, which operates generically
over doubly linked lists.
- Remove `pum_score` and `pum_idx` variables
fixes: #17387
closes: #17430
Signed-off-by: Girish Palya <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>