Problem: MS-Windows: DirectX rendering can be improved
Solution: Use lpDx advance, fix vertical text shift and correct
font-size calculations (Yasuhiro Matsumoto).
This changes DirectWrite rendering to:
- Respect lpDx-provided advance widths instead of always adjusting to
cell width.
- Use a fixed baseline derived from cell geometry to prevent vertical
shifts when font fallback occurs (e.g. with CJK characters).
- Correctly convert LOGFONT lfHeight to DirectWrite font size using font
metrics for closer GDI compatibility.
closes: #19254
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: blob2str() does not handle UTF-16 encoding
(Hirohito Higashi)
Solution: Refactor the code and fix remaining issues, see below
(Yasuhiro Matsumoto).
blob2str() function did not properly handle UTF-16/UCS-2/UTF-32/UCS-4
encodings with endianness suffixes (e.g., utf-16le, utf-16be, ucs-2le).
The encoding name was canonicalized too aggressively, losing the
endianness information needed by iconv.
This change include few fixes:
- Preserve the raw encoding name with endianness suffix for iconv calls
- Normalize encoding names properly: "ucs2be" → "ucs-2be", "utf16le" →
"utf-16le"
- For multi-byte encodings (UTF-16/32, UCS-2/4), convert the entire blob
first, then split by newlines
convert_string() cannot handle UTF-16 because it uses string_convert()
which expects NUL-terminated strings. UTF-16 contains 0x00 bytes within
characters (e.g., "H" = 0x48 0x00), causing premature termination.
Therefore, for UTF-16/32 encodings, the fix uses string_convert_ext()
with an explicit input length to convert the entire blob at once.
The code appends two NUL bytes (ga_append(&blob_ga, NUL) twice) because
UTF-16 requires a 2-byte NUL terminator (0x00 0x00), not a single-byte
NUL.
- src/strings.c: Add from_encoding_raw to preserve endianness, special
handling for UTF-16/32 and UCS-2/4
- src/mbyte.c: Fix convert_setup_ext() to use == ENC_UNICODE instead of
& ENC_UNICODE. The bitwise AND was incorrectly treating UTF-16/UCS-2
(which have ENC_UNICODE + ENC_2BYTE etc.) as UTF-8, causing iconv
setup to be skipped.
fixes: #19198closes: #19246
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: using NOT with a float returns a float in legacy vim script
(kennypete)
Solution: Return a number instead of a float (Yegappan Lakshmanan)
fixes: #19282closes: #19289
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim9: Negating a float doesn't result in a boolean
(kennypete)
Solution: Make it return a boolean (Yegappan Lakshmanan).
related: #19282
related: #19289
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim9: type issue when modifying a variable using :legacy
(kennypete)
Solution: In a vim9 script, when modifying a variable using the legacy
command, check the type (Yegappan Lakshmanan).
fixes: #18531closes: #19292
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: Test_language_cmd fails on OpenBSD because the test
uses an invalid locale name and expects the command to produce
an error. OpenBSD accepts (almost) any locale name as valid by
design, so the :lang command succeeds and the test fails.
Solution: Slightly update the "bad" locale name to make it something
that OpenBSD considers invalid by adding a dot (but not ending
with ".UTF-8"). Maintain the original two underscores in the
name because that ensures Windows will also see it as invalid
(Kevin Goodsell).
closes: #19280
Signed-off-by: Kevin Goodsell <kevin-opensource@omegacrash.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: 'cursorline' and part of 'statusline' are missing after
:diffput to an empty buffer.
Solution: Make sure the cursor doesn't go beyond the last line after
:diffput (zeertzjq)
related: neovim/neovim#37621
closes: #19281
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: unnecessary braces in terminal.c
(Christ van Willegen, after v9.1.2113)
Solution: Remove braces
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: crash when using 'tagfunc' (Rodrigo Queipo)
Solution: Do not add the user_data to the 'info' dictionary when called
for insert mode completion (the TAG_INS_COMP flag is set).
Completion should not depend on the state of a previous tag
jump. (Yasuhiro Matsumoto)
fixes: #19255closes: #19284
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: modeless selection not copied to * register when P in
guioptions (Coacher)
Solution: Make the "P" flag override the "a" and "A" flag
(Foxe Chen)
fixes: #19187closes: #19244
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: long statusline may crash if using singlebyte encoding
(fizz-is-on-the-way)
Solution: Drop the non-mbyte codepath and always use the mbyte code
(zeertzjq)
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: filetype: skhd files are not recognized
Solution: Detect .skhdrc and skhdrc as skhd filetype,
include a syntax and filetype plugin, add syntax tests
(Kiyoon Kim)
Add syntax highlighting for skhd (simple hotkey daemon for macOS)
configuration files. Includes filetype detection for skhdrc and
.skhdrc files.
Reference:
- https://github.com/asmvik/skhdcloses: #19235
Signed-off-by: Kiyoon Kim <kiyoon@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Test_foldtextresult_rightleft() does not restore 'columns'
(after v9.1.2102)
Solution: Save and restore the value of 'columns' (zeertzjq).
related: #19220
closes: #19234
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim9: class, enum and type alias can be used as value in an
expression (kennypete)
Solution: Abort expression evaluation if class, enum or type alias is
used in an expression (Yegappan Lakshmanan)
related: #19173
closes: #19238
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Not enough tests for using plain_vgetc().
Solution: Add tests for using plain_vgetc() during various commands.
(zeertzjq)
closes: #19236
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: readdirex() might be slow (Mao-Yining)
Solution: Avoid double slash in path concatenation in
create_readdirex_item() (Yasuhiro Matsumoto)
On Cygwin and MSYS2, // has a special meaning: it is treated as a prefix
for accessing network computers.
For example, //wsl$/ is used to access WSL.
In the current Vim implementation, the directory path passed to
readdirex() and the file name found during traversal are concatenated
using "/".
When the directory path already ends with /, this results in paths like:
"/" + "/" + "$Recycle.Bin"
which produces a //-prefixed path. Such paths are interpreted as network
paths, so Vim ends up trying to retrieve the file size of a network
computer named $Recycle.Bin, which is not intended.
From a correctness perspective on Windows, file size retrieval should be
skipped for paths of the following forms:
//host
//host/share
However, as a first step, we should avoid generating // paths caused by
redundant / concatenation in the first place.
This change addresses this by preventing unnecessary / insertion when
constructing paths.
fixes: #19188closes: #19241
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tests: test_fold.vim leaves swapfiles behind
Solution: Close open buffer using :bw! instead of :close!
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: foldtext not reversed and cut off in 'rightleft' mode
(bfredl)
Solution: Fix the rightleft redrawing logic (Sergey Vlasov)
fixes: #2659closes: #19220
Signed-off-by: Sergey Vlasov <sergey@vlasov.me>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When checking a .po file (make -C src/po check), errors are not
displayed.
Solution: Adding "silent" to some normal commands in check.vim
suppresses unnecessary output (Muraoka Taro)
This is because the output of check.vim is redirected to /dev/null.
However, if you stop the redirection, check.vim generates a lot of
output and becomes very slow.
When these commands are run in ex mode, they output the contents of the
line the cursor is pointing to. This caused a lot of output.
closes: #19227
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim9: more truthiness issues
(kennypete)
Solution: Class, enum and typealias cannot be used with the falsy
operator (Yegappan Lakshmanan)
related: #19213
fixes: #19173
closes: #19216
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Depending on the worker's environment, the line endings in
ja.sjis.po may differ from those in the source ja.po.
Solution: By setting standard input and output to binary mode, the line
endings for input and output will match (Muraoka Taro)
This occurs when using MINGW gcc on Windows and git with autocrlf=false.
In this case, the line endings in ja.po are LF, but because sjiscorr
compiled with MINGW gcc uses text mode for standard input and output,
the line endings in the output ja.sjis.po will be CRLF.
This mismatch in line endings confuses git, causing large differences to
occur when updating.
In addition, the comment style has been changed to // to match the rest
of Vim's code.
closes: #19226
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Crash with 'wildmenu' when typing Ctrl-Y after Ctrl-A
(after 9.1.1714) (fizz-is-on-the-way).
Solution: Check if there are matches before applying one (zeertzjq).
closes: #19210
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: TabClosedPre may be triggered twice for the same tab page when
closing another tab page in BufWinLeave (after 9.1.1211).
Solution: Store whether TabClosedPre was triggered in tabpage_T
(zeertzjq).
Also fix the inconsistency that :tabclose! triggers TabClosedPre after
a failed :tabclose, but :close! doesn't even if there is only one window
in the tab page.
closes: #19211
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: :wqall! doesn't quit when using :quit in BufWritePost
(after 8.0.1190).
Solution: Restore old value of "exiting" when calling not_exiting()
instead of always resetting it to FALSE (zeertzjq).
related: #2205
closes: #19212
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
I've updated the Japanese translation for the Vim 9.2 release. The
content contained in this PR was created collaboratively by multiple
peoples in the vim-jp/lang-ja project, and I, koron (Muraoka Taro), am
submitting it as the project representative.
The PR used for this work is https://github.com/vim-jp/lang-ja/pull/171.
(Please note that the communication in this PR is in Japanese)
closes: #19215
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: heap-use-after-free when wiping buffer in TabClosedPre.
Solution: Check window_layout_locked() when closing window(s) in another
tabpage (zeertzjq).
closes: #19196
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Ruby headers define HAVE_FSYNC, which leaks into Vim sources
on Windows and changes conditional compilation of buf_T. This
causes struct layout mismatches in if_ruby.c and results in a
different offset for the b_p_bl property, making Vim::Buffer
access fail (after v9.1.2024)
Solution: Undefine HAVE_FSYNC after including the Ruby headers.
related: #19019
closes: #19206
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Last buffer not freed with EXITFREE (after 9.1.2087).
Solution: Free the last buffer when inside free_all_mem()
(zeertzjq).
This isn't really a memory leak, as the last buffer's memory is still
reachable via pointers like firstbuf and lastbuf. But it's possible that
this may cause false ASAN warnings in the future, which is what EXITFREE
is supposed to prevent.
closes: #19194
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Wayland: Clipboard not working with external programs on
Wayland (devsnek)
Solution: Simplify the Wayland offer logic and drop offering the special
mime type (Foxe Chen)
fixes: #19050closes: #19184
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Redundant NULL checks in find_pattern_in_path().
Solution: Remove the NULL checks. Also fix typos in test_diffmode.vim
(zeertzjq).
After assigning to inc_opt on line 3461, it's dereferenced immediately,
and not assigned another value afterwards, so checking for NULL after
line 3462 is redundant.
closes: #19185
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Crash when using :tabonly in BufUnload.
Solution: Set curbuf when setting curwin->w_buffer. Don't wipe out a
buffer if there are no other buffers. Don't decrement
b_nwindows if it was 0 before buf_freeall() (zeertzjq).
fixes: #19088#issuecomment-3710172769
closes: #19186
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: memory leak when not evaluating (just parsing) invalid literal
dict.
Solution: Always clear the key's typval (Sean Dewar)
Though "check_typval_is_value(&tv) == FAIL && !evaluate" is maybe never
true, also always clear tvs if check_typval_is_value fails; at worst
this would be a no-op as their initial types are VAR_UNKNOWN.
closes: #19178
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Use-after-free in winframe_remove() (henices)
Solution: Set window_layout_locked() inside winframe_remove()
and check that writing diff files is disallowed when the
window layout is locked.
It can happen with a custom diff expression when removing a window:
1. Buffer was removed, so win_frame_remove() is called to remove the
window.
2. win_frame_remove() → frame_new_height() → scroll_to_fraction()
→ diff_check_fill() (checks for filler lines)
3. diff_check_fill() ends up causing a diff_try_update, and because we
are not using internal diff, it has to first write the file to a
buffer using buf_write()
4. buf_write() is called for a buffer that is not contained within a
window, so it first calls aucmd_prepbuf() to create a new temporary
window before writing the buffer and then later calls
aucmd_restbuf(), which restores the previous window layout, calling
winframe_remove() again, which will free the window/frame structure,
eventually freeing stuff that will still be accessed at step 2.
closes: #19064
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: modeless auto-select not working
(Coacher)
Solution: Add support for modeless autoselect
(Foxe Chen)
fixes: #19159closes: #19168
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: "#ifdef FEAT_GUI" exists within "ifdef
FEAT_GUI_MSWIN", which is confusing when reading the code.
FEAT_GUI is always defined if FEAT_GUI_MSWIN is defined (see
vim.h). Therefore, this check and the else block are
unnecessary.
Solution: Removed unnecessary "#ifdef FEAT_GUI" (Muraoka Taro).
closes: #19164
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>