Problem: call stack can be corrupted, because calculated remaining
capacity for call stack string can underflow (after v9.1.1983)
Solution: Calculate capacity against maximum capacity
(Sergey Vlasov).
closes: #19759
Signed-off-by: Sergey Vlasov <sergey@vlasov.me>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The check for whether an X connection was opened was incorrect
(after v9.2.0158).
Solution: Use X_DISPLAY instead of xterm_dpy (Shane Harper)
Note: xterm_dpy would be NULL if Vim was started in GUI mode.
Previously, starting two instances of gvim that use GTK3 with:
GDK_BACKEND=x11 gvim and making a visual selection in both would leave
both selections highlighted with the Visual highlight group. Now, when
the second selection is made the first selection will be highlighted
with VisualNOS.
closes: #19752
Signed-off-by: Shane Harper <shane@shaneharper.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: filetype: cto files are not recognized
Solution: Detect *.cto as concerto filetype (Jamie Shorten)
Add filetype detection for the Concerto Modelling Language. Concerto
is a schema language by the Accord Project for defining data models
used in smart legal contracts and business networks.
Reference:
Language spec: https://concerto.accordproject.org
Tree-sitter grammar: https://github.com/accordproject/concerto-tree-sittercloses: #19760
Signed-off-by: Jamie Shorten <jamie@jamieshorten.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: Rendering artifacts with DirectX
(Alexander Zhura)
Solution: Force redraw (Yasuhiro Matsumoto)
DirectWrite subpixel rendering (especially with CFF/OTF fonts) can
extend glyph pixels beyond cell boundaries. Vim already handles the
forward direction (redraw the next character when the current one
changes) for MS-Windows antialiasing, but the backward direction was
missing.
Add gui.directx_enabled flag accessible from screen.c and extend the
existing spill-over handling to:
- Redraw the current character when the previous one changed (backward)
- Force redraw of the next character in screen_puts_len() and
screen_fill() paths
fixes: #19586closes: #19761
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_gui_system_term_scroll() is flaky
(after: v9.2.0208)
Solution: Fix test (Yasuhiro Matsumoto)
Remove timer-based screen check and use a simple command instead
of ping. The timer could fire before ConPTY initialization was
complete, causing screenstring() to return an empty string.
Check screenstring() directly after the command finishes instead.
related: #19735
closes: #19765
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Crash when using a partial or lambda as a clipboard provider
Solution: Don't call free_callback() from clip_provider_get_callback()
(Shane Harper).
closes: #19766
Signed-off-by: Shane Harper <shane@shaneharper.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: version packing may overflow (after v9.2.0206)
Solution: Explicitly clamp the version components using min()
(Mao-Yining).
The version components (major, minor, build) from RtlGetVersion are now
clamped to their maximum bit widths (8 bits, 8 bits, 15 bits) before
being packed into a 32-bit integer. This prevents overflow when storing
unexpectedly large values.
This fixes a regression introduced in patch 9.2.0206 where the previous
clamping logic was accidentally removed.
The MAKE_VER macro is simplified by removing bit masks, as clamping is
now done at the call site, making the macro clearer and reducing
redundant masking.
closes: #19769
Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Normalize white space in the "menu Help->Sponsor" message across all
translation files and the version.c intro handler. This ensures
consistent column alignment when displayed in the user interface.
related: #19771
Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: possible crash when setting 'winhighlight'
Solution: Validate the option value more carefully (Foxe Chen)
closes: #19774
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_xxd tests are failing, after changing the xxd
manpage (after v9.2.0205)
Solution: Update the manpage, shorten the date and update the example,
regenerate the expected test output, skip the first 30 bytes
for the one of the xxd tests (Muraoka Taro)
Some of the Test_xxd tests depend on the contents of xxd.1. The patch
9.2.0205 changed xxd.1, but the test fixes were insufficient. The test
that dumps the beginning of xxd.1 and the test that reads 13 bytes
starting from byte 0x33 from the beginning were failing.
closes: #19763
Co-authored-by: James McCoy <jamessan@debian.org>
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim may freeze if setcmdline() is called while the wildmenu or
cmdline popup menu is active (rendcrx)
Solution: Cleanup completion state if cmdbuff_replaced flag has been set
(Yasuhiro Matsumoto)
fixes: #19742closes: #19744
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: excessive scroll-behaviour with go+=! after
switching to ConPTY as default (after v9.2.0048).
Solution: Use tl_cursor_pos to determine the number of lines to scroll
(Yasuhiro Matsumoto).
Since patch 9.2.0048 (71cc1b12) made ConPTY the default on Windows 11,
running :!cmd with guioptions+=! scrolls up the entire window height
instead of only the output lines.
ConPTY damages all terminal rows on initialization even when they are
empty, which causes tl_dirty_row_end to equal Rows. The scroll-up loop
in update_system_term() then scrolls the full screen because
(Rows - tl_toprow) < tl_dirty_row_end is always true until tl_toprow
reaches 0.
Use the cursor position instead of tl_dirty_row_end for the scroll
calculation, since it reflects where actual content has been written.
The scroll bug only occurs with ConPTY. With winpty the terminal
finishes too quickly for the timer-based screen check to work.
closes: #19735
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: freeze on second :hardcopy
(antoniopaolini)
Solution: Enable PrintHookProc in GUI mode to ensure the print dialog is
brought to the foreground (Yasuhiro Matsumoto).
Enable PrintHookProc for GUI mode so that the print dialog is brought
to the foreground via BringWindowToTop/SetForegroundWindow. Without
the hook, the second PrintDlgW() modal dialog appears behind gvim due
to Windows foreground lock timeout, making gvim unresponsive.
Also add NULL checks for hDlgPrint in SendMessage calls.
fixes: #19715closes: #19754
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Window: stripping all CSI sequences
(Ke Mao, after v9.2.0184)
Solution: Restore vtp_printf() to pass-through DECSUSR codes
(Yasuhiro Matsumoto).
Patch 9.2.0184 discards all CSI sequences in mch_write() when VTP is
active to prevent unwanted DECRQM responses. However, this also
removed the existing DECSCUSR pass-through, breaking cursor shape
changes (t_SI/t_SR/t_EI) on Windows Terminal.
Restore vtp_printf() pass-through for DECSCUSR (final byte 'q') while
continuing to discard other CSI sequences.
related: #19694
related: #11532
fixes: #19750
closes: #19755
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: xxd: Cannot NUL terminate the C include file style
Solution: Add option -t to end output with terminating null
(Lukáš Jiřiště).
fixes: #14409closes: #19745
Signed-off-by: Lukáš Jiřiště <kyci@ljiriste.work>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The glob() function on Unix-like systems does not escape
newline characters when expanding wildcards. A maliciously
crafted string containing '\n' can be used as a command
separator to execute arbitrary shell commands via
mch_expand_wildcards(). This depends on the user's 'shell'
setting.
Solution: Add the newline character ('\n') to the SHELL_SPECIAL
definition to ensure it is properly escaped before being
passed to the shell (pyllyukko).
closes: #19746
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-w5jw-f54h-x46c
Signed-off-by: pyllyukko <pyllyukko@maimed.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: term: DECRQM codes are sent too early, the resulting DECRPM
responses can arrive after Vim has already exited, leaking
into the shell's input buffer (Christian Brabandt).
Solution: Only send DECRQM codes once termcap_active is set
(Foxe Chen).
related: #19660
fixes: #19660#issuecomment-4085448070
closes: #19748
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: test_startup.vim fails, because the command line is
getting too long so that the shell prompt line get shifted by one
additional screen line down (after v9.2.0194).
Solution: Partly revert Patch v9.2.0194 and do not set termresize and
termsync options.
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: cscope: can escape from restricted mode (pyllyukko)
Solution: Disallow :cscope in restricted mode (like :grep),
add a tests for restricted mode using :grep and :cscope
closes: #19731
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When 'showtabpanel' is set before any window exists (e.g. via
--cmd) and multiple tab pages are opened with -p, the tabpanel
appears when the second tab page is created. At that point
shell_new_columns() only updates the current (new) tab page's
frame width; existing tab pages retain the wrong width.
Solution: After calling shell_new_columns() in win_new_tabpage(), iterate
all other tab pages and update their frame widths with
frame_new_width() (Hirohito Higashi).
related: #19730
closes: #19734
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Add a minimal ftplugin `runtime/ftplugin/yara.vim` that sets:
- `commentstring` for YARA line comments (`//`)
- `comments` for YARA block comment (`/* */`)
- `formatoptions` to wrap comment lines and continue comment after newlines
This was heavily inspired from `runtime/ftplugin/c.vim`
closes: #19736
Signed-off-by: Thomas Dupuy <thom4s.d@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: textprop: negative IDs and can cause a crash without "text"
(Paul Ollis)
Solution: Strictly reserve negative IDs for virtual text, ignore "id"
when "text" is provided in prop_add() (Hirohito Higashi).
When prop_add() was called with a negative id and no "text", the
property was stored with a negative tp_id. A subsequent call to
prop_list() or screen redraw would then treat it as a virtual text
property and dereference b_textprop_text.ga_data, which is NULL when
no virtual text properties exist.
Negative ids are reserved for virtual text properties, so always
reject them with E1293 regardless of whether virtual text properties
exist. Also, when "text" is specified any user-provided id is now
silently ignored and an internal negative id is assigned.
Remove the now-unnecessary did_use_negative_pop_id flag and E1339.
Update E1293's message and the documentation accordingly.
related: #19684
closes: #19741
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: test_codestyle.vim takes too much time and takes more than
90s, this contributes to the overall time for all runners and
Solution: Create a dedicated 'make codestyle' target in the testdir
Makefiles. Remove test_codestyle from the main test list.
Update GitHub CI to run this check as a separate step
in the 'normal' features build.
Increase CI timeout to 45 minutes.
fixes: #19740
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: test_startup.vim leaves temp.txt around
Solution: Disable termresize and termsync explicitly to stop outputting
DEC mode chars, delete all chars before the rm command
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: using copy_option_part() can be improved
Solution: Refactor and use the return value of copy_option_part() to
avoid strlen() calls (John Marriott).
In addition, this commit includes the following changes:
memline.c:
- In recover_names():
- Replace calls to vim_strsave() with vim_strnsave() for the literal
strings
- Use a string_T to store local variable dir_name.
bufwrite.c:
- In buf_write()
- move variable wp to where it is used.
help.c:
- In fix_help_buffer():
- replace call to add_pathsep() with after_pathsep()
optionstr.c:
- In export_myvimdir():
- use a string_T to store local variable buf
- replace call to add_pathsep() with after_pathsep()
scriptfile.c:
- In do_in_path():
- use a string_T to store local variable buf
- measure the lengths of prefix and name once before the while loop
- replace call to add_pathsep() with after_pathsep()
- move some variables closer to where they are used
spellfile.c:
- In init_spellfile():
- use a string_T to store local variable buf
closes: #19725
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When "k" is excluded from cpoptions, vim should be able to
recognize raw key codes in mappings and replace them with
builtin codes (e.g. ^[OA is replaced with <Up>) so that
changing the builtin code also changes the mapping to match.
Currently, this only works properly if the builtin code does
not contain modifiers (e.g. @;*).
Solution: Teach find_term_bykeys how to recognize keys with modifiers
(AstroSnail).
fixes: #19182closes: #19643
Signed-off-by: AstroSnail <astrosnail@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The "android" and "termux" feature flags have been shipped in
Termux's downstream vim / vim-gtk package for 5+ years but were
never properly documented in the downstream patch.
Solution: Upstream the "android" and "termux" feature flags into Vim as
decoupled feature flags, this enables the "android" feature in
particular to be available independently of the "termux"
feature for builds of Vim against the Android NDK, but not
including the Termux NDK patchset.
closes: #19623
Co-authored-by: Lethal Lisa <43791059+lethal-lisa@users.noreply.github.com>
Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>
Signed-off-by: TomIO <tom@termux.dev>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When 'laststatus' changes, the status line can become
misaligned.
Solution: Update last_status_rec() to calculate the maximum status line
height required across all windows in a vertical row.
closes: #19688
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When using transparent popups in the Win32 console, redrawing
background windows causes flickering. This happens because
the background is drawn opaquely before the popup blends
and draws on top.
Solution: Implement a Z-index mask to suppress screen_char() output for
cells covered by an opacity popup. Disable the Clear-to-EOL
(T_CE) optimization for lines overlapping these popups to
prevent accidental erasure (Yasuhiro Matsumoto).
closes: #19697
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: rendering artifacts with DirectX renderer
Solution: Enable ETO_CLIPPED for DirectWrite rendering in
gui_mch_draw_string() to ensure glyphs stay within their
cell boundaries (Yasuhiro Matsumoto).
closes: #19711
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Using a long generic function name may cause a heap buffer
overflow in common_function().
Solution: Allocate memory for the full name instead of using IObuff
(Kaixuan Li).
closes: #19727
Signed-off-by: Kaixuan Li <kaixuanli0131@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When drawing a custom tabline, if topframe->fr_width is
larger than Columns (possible during tab closure with
showtabpanel=1), Vim writes past the end of the
TabPageIdxs[] array.
Solution: Cap the column limit at Columns to ensure TabPageIdxs is
never accessed out-of-bounds (thinca).
closes: #19725
Supported by AI
Signed-off-by: thinca <thinca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When 'termguicolors' is used on MS-Windows (VTP mode), sending
CSI query sequences (like DECRQM) causes the console to
generate responses that are misinterpreted as keystrokes.
The leading ESC triggers a beep or 'visualbell' flash.
Solution: In mch_write(), discard CSI sequences when USE_VTP is active
so the console does not process queries and generate unwanted
input responses (Yasuhiro Matsumoto).
related: #11532
closes: #19694
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: gethostbyname() and inet_ntoa() are deprecated and cause
build errors on modern MSVC versions.
Solution: Use getaddrinfo() and inet_ntop() when FEAT_IPV6 and
HAVE_INET_NTOP are defined. Keep the old functions as
fallbacks for legacy platforms (Yasuhiro Matsumoto).
closes: #19719
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: autocmds that switch windows may cause them to remain with
w_locked set, preventing them from being closed longer than
intended.
Solution: Unset w_locked in the window where it was set (Sean Dewar).
closes: #19716
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: line('w0') moves cursor in terminal-normal mode
(Biebar, after v9.2.0127)
Solution: Check that the terminal is not in terminal-normal-mode
(Ozaki Kiichi).
fixes: #19717closes: #19718
Signed-off-by: Ozaki Kiichi <gclient.gaap@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>