Problem: Memory leak in error path of copy_substring_from_pos().
Solution: Free the garray on OOM in copy_substring_from_pos()
(glepnir).
closes: #20086
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: A <Cmd> command in Insert mode can edit the current buffer,
e.g., with setline(). That edit appends to the current undo
block, but Insert mode does not know that the cursor line may
need to be saved again before the next typed edit. If the next
typed edit is a <BS> at the start of a line, it can join away
the line that was changed by the <Cmd> command before Insert
mode saves that updated line. The newest undo entry can then
still refer to the joined-away line, so undo sees a range past
the end of the buffer and fails with E438.
Solution: If a <Cmd> command in Insert mode changes the buffer, set
ins_need_undo so stop_arrow() refreshes Insstart. This lets
the next edit properly decide whether a new undo entry is
needed (Jaehwang Jung)
closes: #20087
AI-assisted: Codex
Signed-off-by: Jaehwang Jung <tomtomjhj@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Several issues around the tabpanel scrollbar:
1. :set tabpanelopt= completion did not offer "scroll" and
"scrollbar".
2. gt/gT and other tab switches did not update the scrollbar
thumb; the current tab could move outside the visible
panel range without the view following.
3. When tpl_scroll_offset was at its maximum, the thumb's
bottom did not reach the last screen row due to integer
truncation in thumb_top (e.g. 31 tabs on 24 rows + :tablast
left a one-row gap).
4. For align:right the scrollbar was drawn on the panel's
left edge (adjacent to the buffer area), which breaks the
common convention that a vertical scrollbar sits on the
right.
Solution: - Add "scroll" and "scrollbar" to the 'tabpanelopt' expansion
list. Cover the completion in test_options.vim and extend
util/gen_opt_test.vim with the new valid/invalid values;
drop the now-redundant acceptance test from
test_tabpanel.vim.
- In draw_tabpanel(), remember the last-drawn curtab and,
when it changes, adjust tpl_scroll_offset so curtab_row
falls inside [offset, offset + Rows). Mouse wheel and
drag leave curtab unchanged, so the user's chosen offset
is preserved.
- In draw_tabpanel_scrollbar(), compute thumb_top as
(Rows - thumb_height) * tpl_scroll_offset
/ (tpl_total_rows - Rows), mirroring the mapping already
used by tabpanel_drag_scrollbar(). This guarantees the
thumb's bottom reaches the last row at the maximum offset.
- In draw_tabpanel(), place the scrollbar at the tabpanel's
right edge for both align:left and align:right (previously
align:right put it on the panel's left edge next to the
vertical separator). For align:right this means the
scrollbar now sits at the screen's right edge.
- Update :h tabpanel-scroll to describe the new, align-
independent placement.
- Add Test_tabpanel_scrollbar_follows_curtab() and
Test_tabpanel_scrollbar_reaches_bottom() to exercise the
regressions fixed by items 2 and 3.
closes: #20052
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: when jumping to tags, will open URLs
(Srinivas Piskala Ganesh Babu)
Solution: Disallow trying to open remote files.
closes: #20068
Supported by AI
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: redraw_listener_add() does not check secure flag
Solution: Check for check_secure() in f_redraw_listener_add()
closes: #20070
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim9: def function sandbox bypass
(Srinivas Piskala Ganesh Babu)
Solution: Check for sandbox flag in call_user_func() and call_dfunc()
when executing Vim9 script functions
closes: #20071
Supported by AI
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: pum: opacity not applied to wildmenu pum
Solution: Call pum_call_update_screen() in cmdline_pum_display() when
opacity is set, fix flicker by checking against expected row
(Yasuhiro Matsumoto).
closes: #20072
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: still a few flaky tests
Solution: Add WaitForAssert to test_messages.vim, use a smaller terminal
window for test_tabpanel, add TermWait() in test_messages
to handle DECQRM messages.
closes: #20074
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Modeline-tainted 'complete' values can invoke completion
callbacks outside the sandbox.
Solution: Enter the sandbox for both 'complete' callback phases and add
a regression test (Barrett Ruth)
closes: #20078
Signed-off-by: Barrett Ruth <br.barrettruth@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: compile warning in strptime.c
(John Marriott, after v9.2.0398)
Solution: Fix the compile warning (Yasuhiro Matsumoto).
Use _get_tzname() instead of the deprecated tzname[] global on UCRT and
MSVC builds; older MinGW (msvcrt.dll) keeps using tzname[] as a
fallback.
related: #20054
closes: #20079
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: missing strptime() support
Solution: Port NetBSD's strptime fallback to Vim
(Yasuhiro Matsumoto).
The MSVC and MinGW C runtimes do not provide strptime(), so the
strptime() builtin was unavailable on Windows. Port NetBSD's
lib/libc/time/strptime.c (rev 1.67) and compile it into the Windows
builds. The BSD 2-clause notice from the original is preserved in the
file. Windows-specific adjustments: English-only locale tables, the
fromzone()/tzalloc() path is stubbed out (no IANA tzfile loader on
Windows), and tm_gmtoff / tm_zone stores are elided.
Also call tzset() before mktime() in f_strptime() so changes to \$TZ
are honored.
Skip the POSIX DST TZ assertion in Test_strptime() on MS-Windows since
the CRT tzset() does not parse POSIX TZ strings with DST rules.
closes: #20054
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tabpanel: double-click opens a new tab page
Solution: Do not create a new tab page when using a double click
(Yasuhiro Matsumoto).
The tabpanel click handler inherited the tabline behavior where a
double-click opens a new, empty tab page. Unlike the tabline, the
tabpanel has no "empty area": every row maps to some tab, so this
fires on any double-click in the tabpanel and can generate stray
empty tabs. The behavior is also not documented for the tabpanel.
Skip the new-tab branch when the click originated in the tabpanel
and fall through to the regular tab-switch path instead. The
tabline behavior is unchanged.
closes: #20044
Signed-off-by: Christian Brabandt <cb@256bit.org>
- Fix regex highlighting after opening parens, javascriptParens was
matching later. Fixes issue #20069.
- Add missing regex flags.
- Mark the file as unmaintained. Thanks Claudio for all your work.
closes: #20076
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
To check for an existing HelpComplete function, exists('*HelpComplete')
should be used, as exists('HelpComplete') still returns 0 after sourcing
the ftplugin.
closes: #20073
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
- Add a syntax file update to Neville Dempsey's long-serving version
- Add a new rudimentary ftplugin
- Add filetype detection
Changes to the syntax file include:
- improved prelude, number and symbol highlighting
- prelude highlighting tests
- updated boiler plate
Note that these runtime files currently target Algol 68 Genie employing
the default UPPER stropping regime. Support for GNU Algol 68 should
also be usable with the UPPER stropping regime, although somewhat less
complete. Full support for the SUPPER stropping regime in GNU Algol 68
is also planned.
closes: #19818
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Janis Papanagnou <janis_papanagnou@hotmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Allow for docker comments to be interspersed in a multiline (continued)
RUN command argument.
fixes: #8364closes: #19829
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_error_callback_terminal is flaky on macOS
Solution: Use WaitForAssert() to make it more reliable
(Yasuhiro Matsumoto).
term_wait() only waits for terminal screen updates and does not
guarantee that the err_io 'pipe' callback has fired, so on macOS
the assert_match() against g:error frequently runs before sh has
written "sh: XXXX: not found", causing the test to flake.
Replace term_wait() + assert_match() with WaitForAssert() so each
assertion polls until the callback delivers the expected output.
Also defer sending "exit" until the stderr message has been seen,
to avoid losing the stderr write to the exit race.
closes: #20075
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_backupskip() may read from $HOME
Solution: Set $HOME to an empty value, use --clean
(D Ben Knoble)
Even though we unset HOME, we can see via scriptnames that user files
are still sourced! One of my installed plugins warns when not compiled
with +python3, so this test has a "press Enter" prompt.
Use `--clean` like most other GetVimProg()'s do to fix it. Some tests
use `system()` instead, but that turns this test into a failure rather
than passing; I'm not sure why other tests don't suffer from this.
To prove to ourselves, we can use code like this:
diff --git i/src/testdir/test_options.vim w/src/testdir/test_options.vim
index a408e20e1..044364a54 100644
--- i/src/testdir/test_options.vim
+++ w/src/testdir/test_options.vim
@@ -1179,6 +1179,7 @@ func Test_backupskip()
" P_NODUP). Run this in a separate instance and write v:errors in a file,
" so that we see what happens on startup.
let after =<< trim [CODE]
+ call writefile([execute('scriptnames')], 'foo')
let bsklist = split(&backupskip, ',')
call assert_equal(uniq(copy(bsklist)), bsklist)
call writefile(['errors:'] + v:errors, 'Xtestout')
@@ -1196,7 +1197,7 @@ func Test_backupskip()
" unset $HOME, so that it won't try to read init files
let saveenv['HOME'] = getenv("HOME")
call setenv('HOME', v:null)
- exe 'silent !' . cmd
+ exe 'silent !' . cmd .. ' --cmd "echo &rtp"'
call assert_equal(['errors:'], readfile('Xtestout'))
" restore environment variables
Here, that causes "foo" to include a bunch of files under ~/.vim. I'm
not sure why this happens, but lets paper over it for the test.
We can also tell that (orthogonal to --clean) setting HOME='' works too.
Let's do that in addition since unsetting HOME isn't quite enough.
closes: #20051
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: xxd: offsets greater than LONG_MAX print as negative
Solution: Use "%lu" to print unsigned long value
(Yasuhiro Matsumoto)
closes: #20055
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: No guidance for AI coding agents working in the Vim
repository.
Solution: Add AGENTS.md to the repository documenting build
and test commands, repository layout, commit format,
C and Vim9-script conventions, test conventions, help
file style, and release policy, so that AI agents can
produce patches that match project expectations.
closes: #20039
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: link error with XPM support on UCRT64
Solution: Make_cyg_ming.mak: allow XPM to point to system layout with
X11/ headers (Yasuhiro Matsumoto)
When XPM is set to a system prefix such as /msys64/ucrt64 (where xpm.h
lives in include/X11/), the existing -I flags miss the header. Add
-I $(XPM)/include/X11 so both the bundled layout (xpm/include/xpm.h)
and the system layout (include/X11/xpm.h) work.
closes: #20064
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Some tests are flaky and cause CI to fail
Solution: Add WaitForAsserts() calls to reduce flakiness
closes: #20050
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Comment in test_vim9_cmd breaks syntax highlighting
Solution: Move the comment into the function and use the # as comment
marker instead
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: filetype: some Beancount files are not recognized
Solution: Detect *.bean files as beancount filetype
(Bruno Belanyi)
closes: #20037
Signed-off-by: Bruno Belanyi <bruno@belanyi.fr>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: DECRQM was still sent to Apple Terminal.app before its DA2
reply was processed, leaving a literal "pp" on screen.
may_req_decrqm() was called from vim_main2()
right after may_req_termresponse(), at which point
term_props[TPR_DECRQM].tpr_status was still TPR_UNKNOWN, so
the `!= TPR_NO` guard let the request through (after v9.2.0387)
Solution: Send DECRQM from handle_version_response() once
term_props[TPR_DECRQM].tpr_status == TPR_YES, the same
pattern already used for t_RS (TPR_CURSOR_STYLE) and t_RC
(TPR_CURSOR_BLINK), which deliberately wait for the DA2
reply to avoid the same echo-on-screen issue on Apple
Terminal.app and Gnome terminal. Drop the now-unused
may_req_decrqm() helper and its call site in vim_main2()
(Hirohito Higashi).
fixes: #19852
related: #19938
closes: #20038
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: John Marriott <basilisk@internode.on.net>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Sending DECRQM from handle_version_response() caused DECRPM
responses to arrive during user input processing, leaving
bytes in typebuf when clear_showcmd() ran. This made
visual-mode showcmd (e.g. "7" line count after V<C-D><C-D>)
intermittently disappear, failing many screendump tests on CI.
Solution: Move DECRQM request out of handle_version_response() and send
it at startup via may_req_decrqm(), following the existing
may_req_termresponse() and may_req_bg_color() pattern.
Add TPR_DECRQM property set per terminal from the DA2 reply,
and route DECRQM sends through a may_req_decrqm() helper using
the termrequest_T pattern, skipping terminals known to
mishandle it (Foxe Chen, Hirohito Higashi).
fixes: #19852closes: #19938
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Hirohito Higashi <h.east.727@gmail.com>
Co-Authored-By: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: No scroll/scrollbar support in the tabpanel
Solution: Add support for it (Yasuhiro Matsumoto)
closes: #19979
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Code like ${!#} flags the "#" as shDerefWordError [1]; the "!prefix"
syntax region delegates to one of the shDerefSpecial handlers via
@shDerefList, but it misses the "#" case as valid for ${##} and ${!#}.
[1]: https://vi.stackexchange.com/q/48617/10604
Correct that. Indirection is only valid in Bash in Ksh, so rearrange the
"!" handling to be conditional.
closes: #20016
Helped-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Integer overflow with "ze" and large 'sidescrolloff'.
Solution: Check for overflow to avoid negative w_leftcol (zeertzjq).
closes: #20026
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
A new graphqlEscape syntax graph has been introduced to represent escape
sequences within strings, including the braced unicode form (\u{H+})
added in the September 2025 specification.
See: https://spec.graphql.org/September2025/closes: #20030
Signed-off-by: Jon Parise <jon@indelible.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: A <Cmd> command executed from Insert mode can sync undo and
move the cursor before the next edit. stop_arrow() saved the
new cursor line for undo, but left Insstart at the previous
insertion point. A line-start backspace could then delete
lines above the saved line without saving the joined range,
leaving a pending undo entry whose bottom resolved above
its top and raising E340.
Solution: Update Insstart and Insstart_textlen after the pending undo
save so the next edit starts from the command-updated cursor
position (Jaehwang Jung).
closes: #20031
AI-assisted: Codex
Signed-off-by: Jaehwang Jung <tomtomjhj@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: runtime(netrw): shell-injection via sftp: and file: URLs
(Joshua Rogers)
Solution: Escape temporary file names, harden filename suffix regex,
drop unused g:netrw_tmpfile_escape variable
Supported by AI
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Wayland: focus-stealing is non-working
Solution: Remove it, the feature could be re-implemented using
clipboard-providers feature, see :h wayland-primary-selection
(Foxe Chen).
closes: #19984
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: ins_compl_stop() sets compl_best_matches = 0, but that's a
pointer, should reset compl_num_bests instead,
find_common_prefix() reads cpt_sources_array[cur_source] without
checking cur_source != -1 which causes an OOB for -1,
find_next_completion_match(): second `if` in the pending loop
should be `else if`. Forward paging only moves one step per call.
Solution: Reset compl_num_bests instead, add a check for cur_source not
equal -1, change if to else if (glepnir)
closes: #20000
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: gui.color_approx in gui_T has not been assigned anywhere since
patch 7.4.2094 ("The color allocation in X11 is overly
complicated", 2016), which dropped the single "gui.color_approx = TRUE;"
site. Because the member is zero-initialized and never written, the
check "if (gui.color_approx)" in gui_mch_init() is always false and the
"E458: Cannot allocate colormap entry, ..." warning can never be
emitted.
Solution: Remove the struct member and the unreachable branch. The E458
error definition is removed. Update the example error code
"E458" in the ex_eval.c comment to "E457" accordingly.
closes: #20007
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Several win_T fields are declared as "int" or "char" but are
used strictly as boolean flags with TRUE/FALSE values. The
integer types obscure the boolean intent and are wider than
needed.
Solution: Change the following win_T members to bool (stdbool.h) and
update their assignments from TRUE/FALSE to true/false
accordingly.
The following conversions have been done:
- int -> bool (10 members):
w_set_curswant, w_botfill, w_old_botfill, w_do_win_fix_cursor,
w_popup_fixed, w_border_highlight_isset, w_cline_folded,
w_redr_status, w_arg_idx_invalid, w_has_scrollbar
- char -> bool (4 members):
w_topline_was_set, w_ru_empty, w_fold_manual, w_foldinvalid
No existing code compares these members against TRUE/FALSE explicitly or
uses ++/-- / bitwise ops on them, so only plain assignments are
affected.
Excluded:
- w_locked (recursion counter with ++/--),
- w_want_scrollbar (may hold -1 from dict_get_bool),
- w_winbar_height (used in arithmetic and exposed as number via
getwininfo()).
related: #20005
closes: #20008
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Several gui_T fields are declared as "int" or "char" but are
used strictly as boolean flags with TRUE/FALSE values. The
integer types obscure the boolean intent and are wider than
needed.
Solution: Change the following gui_T members to bool (stdbool.h) and
update their assignments from TRUE/FALSE to true/false
accordingly (Hirohito Higashi)
The following conversions have been done:
- int -> bool (11 members):
in_focus, in_use, starting, dying, dofork, dospawn,
pointer_hidden, force_redraw, directx_enabled, font_can_bold,
which_scrollbars[3]
- char -> bool (2 members):
cursor_is_valid, menu_is_active
No existing code compares these members against TRUE/FALSE explicitly
(e.g. "== TRUE"), so only plain assignments are affected.
gui_init() used counter-style "--gui.starting" / "++gui.starting" to
temporarily clear the flag across a call to gui_mch_enable_menu().
With gui.starting now bool this triggers -Werror=bool-operation, so
replace it with an explicit save/restore.
X11 Bool members (rsrc_rev_video, color_approx) are intentionally left
unchanged: rsrc_rev_video is registered as an X Toolkit resource with
XtRBool / sizeof(Bool) and must keep the int-sized X11 Bool type.
closes: #20005
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When an `if` condition is constant true, the `else` block is
skipped during compilation. However, any `elseif` condition
within that skipped block was still compiled. This caused
errors when the condition referenced variables only declared
in the skipped block or when it checked for missing features
(like `has('clipboard')`) (Coacher)
Solution: In compile_elseif(), when scope->se_skip_save is
already SKIP_YES, skip compiling the elseif condition
expression using skip_expr_cctx() (Furkan Sahin)
fixes: #19160closes: #20021
Signed-off-by: Furkan Sahin <furkan-dev@proton.me>
Signed-off-by: Christian Brabandt <cb@256bit.org>