Problem: stray p character displayed on some terms
Solution: Make sending DECRQM more strict and disable it for a few more
terminals (Foxe Chen)
fixes: #20156
fixes: #20140closes: #20161
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: MS-Windows: cursor flicker during update_screen()
Solution: Hide the cursor during update_screen() to avoid Windows ConPTY
flicker (Yasuhiro Matsumoto).
On terminals that do not honor synchronized output mode (e.g. Windows
ConPTY), update_screen() emits cell positioning and content as multiple
Win32 console writes through mch_write(), which the terminal renders as
separate frames. This shows up as the cursor briefly jumping to column
1 of rows being redrawn, especially during async redraws around the
popup completion menu.
Disable the cursor with cursor_off() at the start of update_screen()
and restore it with cursor_on() at the end, but only when synchronized
output mode is not active. When it is, the redraw is already atomic
from the terminal's view and hiding the cursor would only add visible
blink with no benefit.
closes: #20121
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
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: too many strlen() calls when adding strings to dicts
Solution: Refactor code to use string_T, use dict_add_string_len()
instead of dict_add_string() (John Marriott)
Additionally:
- In textprop.c, in function prop_fill_dict() use a string_T to store
local variable text_align.
- In popupwin.c, use a string_T to store struct member pp_name in struct
poppos_entry_T.
- In mark.c, refactor function add_mark() to pass in the length of
argument mname.
- In insexpand.c:
->Use a string_T to store the elements of static array
ctrl_x_mode_names.
->Refactor function trigger_complete_done_event():
->->change type of argument char_u *word to string_T *word.
->->make one access of array ctrl_x_mode_names instead of two.
->Refactor function ins_compl_mode() to accept a string_T to return the
resulting string.
- In fileio.c:
->Refactor function getftypewfd() to accept a string_T to return the
resulting string.
->In function create_readdirex_item() use a string_T to store local
variable q.
- In cmdexpand.c, store global cmdline_orig as a string_T.
- In autocmd.c, in function f_autocmd_get() use a string_T to store local
variables event_name and group_name. Measure their lengths once when
they are assigned so they are not remeasured on each call to
dict_add_string() in the subsequent for loop.
- In channel.c, in function channel_part_info() drop local variable status
and use s instead. Make s a string_T.
closes: #19999
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
problem: unnecessary work in vim_strchr() and find_term_bykeys()
Solution: Redirect vim_strchr() to vim_strbyte() for ASCII input
Add an early exit to find_term_bykeys() using the terminal
leader table, mirroring check_termcode(). Reduces instruction
count on startup by about 27%. (Yasuhiro Matsumoto)
closes: #19902
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Some internal variables are not modified
Solution: Add const qualifier to static table data
(Hirohito Higashi).
Several static arrays that are never modified at runtime were missing the
const qualifier. Add const to move them from .data to .rodata section.
closes: #19901
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: BSU/ESU are output directly to the terminal
Solution: Route them through out_buf() and flush the output directly,
increase the OUT_SIZE terminal buffer (Yasuhiro Matsumoto)
Route synchronized-output control sequences through out_buf and flush
explicitly at protocol boundaries, instead of forcing BSU/ESU through
ui_write() directly.
Also increase the terminal output buffer from 2047 to 8191 bytes so
large redraws are emitted in fewer writes.
The important guarantee here is terminal-visible ordering: BSU must
reach the terminal before the batched redraw bytes, ESU must reach the
terminal after them, and FLUSH must emit ESU and BSU together, then
flush immediately.
Benchmark: PTY redraw workload with TERM=xterm-256color, long wrapped
lines, cursorline, listchars, horizontal scrolling, and repeated redraw!.
write syscalls: 8514 -> 5094 (-40.2%)
wall time: 0.568s -> 0.495s (-12.9%) on valid runs in this environment
closes: #19862
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: In XTerm, with 'xtermcodes' enabled (default), vim will
request keypad keys after editing pad keys, and will remove
the latter when they're duplicates of the former.
Solution: When a termcode reply is a keypad key and it would replace a
different key, skip it.
fixes: #19182 (case 2)
related: #19643
closes: #19644
Signed-off-by: AstroSnail <astrosnail@protonmail.com>
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: 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: Vim sends DEC mode query requests (DECRQM) regardless of the
terminal mode.
Solution: Only send DEC mode requests when cur_tmode is TMODE_RAW, but
e.g not for gui mode (Foxe Chen).
fixes: #19709closes: #19710
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: intro message disappears on startup in some terminals
(chdiza, after v9.2.0139)
Solution: Only call set_shellsize() in handle_csi() if the reported
width or height actually differs from the current
Rows or Columns. (Foxe Chen)
fixes: #19656closes: #19660
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: When using synchronized terminal output, the internal
output buffer is not flushed before sending the
End Synchronized Update (ESU) sequence. This causes
redrawing artifacts.
Solution: Call out_flush() immediately before sending the ESU
sequence to ensure all pending drawing commands are
contained within the synchronized update window.
(Yasuhiro Matsumoto)
closes: #19662
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: No support for terminal synchronization mode
Solution: Add DEC 2026 support using the 'termsync' option
(Foxe Chen).
related: #11718
closes: #19541
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Coverity complains about uninitialized var, also gcc warns
about a few other variables possibly being used uninitialized
(Tony Mechelynck, after v9.2.0093)
Solution: Initialize a few other variables.
Coverity CID: 1683101
closes: #19561
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: In XTerm, typing Home, End, PgUp or PgDn on the editing pad
will cause vim to recognize <kHome>, <kEnd>, <kPageUp> or
<kPageDown> (keypad keys) instead of <Home>, <End>, <PageUp>
or <PageDown> (editing pad keys) respectively, affecting
mappings and the :terminal. This is caused because the keypad
termcaps are sorted before the editing pad ones in
termcodes, meaning vim will match the former if they are the
same.
Solution: Only recognize keypad keys when nothing else matches
(AstroSnail).
fixes: #17331closes: #19145
Signed-off-by: AstroSnail <astrosnail@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Vim gets confused by OSC handling, causing Vim to start in
search mode (Shane Harper, after v9.1.1703)
Solution: In handle_mapping(), check if we are handling OSC sequences
and if yes go straight to check_termcode() (Foxe Chen)
fixes: #19426closes: #19435
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: ANSI escape colors are not displayed correctly in
non-termguicolors in vim (cli) on Windows. The red and blue
channels seem to be swapped.
Cause: When converting VTerm ANSI index colors to cterm colors in
terminal.c, the Windows case equivalent to NR-16 (:help
cterm-colors) is ignored.
Solution: Created and used a table to convert ANSI indexed colors to
cterm's NR-16 representation (Windows only). This table
corresponds to the inverse conversion of cterm_ansi_idx in
term.c. The values in both tables are exactly the same, but
the meanings are opposite, so they are separate tables
(Muraoka Taro).
closes: #18931
Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: build failure on Solaris Sparc with gcc 5
(idgn23, after v9.1.1736)
Solution: Correctly initialize the key_name variable.
fixes: #18693
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Generating prototype files does not work on all platforms
Solution: Rework prototypes generation using python instead of cproto,
enable it in CI to test it for each PR (Hirohito Higashi).
closes: #18045
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: completion: flicker with slow LSPs
Solution: Disable flushing the changed text (Girish Palya).
In insert-mode completion, the leader text is temporarily deleted while
searching for completion candidates. If the LSP server responds slowly,
the client may call `:sleep` to wait, which triggers `out_flush()`. This
causes the deleted text to briefly disappear before being redrawn when
results arrive, producing a visible flicker.
There are two possible fixes:
1. Suppress flushing while a user function (e.g. LSP client) is waiting.
2. Reinsert the deleted text before invoking the user function.
This Commit implements (1), which is the simpler solution, though somewhat
heavy-handed. If you think this may introduce unwanted side effects, I
can rework it to use (2).
closes: #18439
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: The colorresp plugin causes additional redraws
(Linwei, after v9.1.1703)
Solution: Move the code back into the C core and get rid of the vim
plugin (Foxe Chen)
fixes: #18251closes: #18279
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Regression with kitty protocol and trailing byte "u"
(chdiza, after v9.1.1736)
Solution: Check that trailing byte "~" is present
fixes: #18232closes: #18234
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Cannot detect <F3> using kitty protocol
Solution: Handle and detect Kitty keys when using the trailing "~" byte
fixes: #18100closes: #18126
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: screen not redrawn properly on t_RB response (after v9.1.1703)
Solution: Call redraw_asap() if necessary (Julio B)
closes: #18149
Signed-off-by: Julio B <julio.bacel@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: no support for terminal primary device attributes
Solution: Add support for detecting the DA1 response from the terminal,
add the v:termda1 variable and the 't_Ms' option for the
OSC 52 command format (Foxe Chen)
closes: #18033
Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: Issues with proto files: missing or inconsistent prototypes.
Solution: Update ifdefs, move typedefs, fix prototype declaration
(Hirohito Higashi)
This change focuses on fixes and tweaks found while working on #18045 for
the proto/*.pro files.
The following fixes and tweaks have been made:
- Fixed a prototype declaration where the variable name differed from
the function definition.
- Removed a prototype declaration without a function body.
- Fixed a problem where a prototype declaration was not created for a
function definition enclosed in a #if directive because it lacked ||
defined(PROTO).
- Moved typedef struct soundcb_S soundcb_T; from proto/sound.pro to
vim.h.
- Other small tweaks.
The make proto mechanism remains unchanged.
closes: #18058
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: missing change from patch v9.1.1461
Solution: change wrong TPL_LCOL macro in a few more places
Signed-off-by: Christian Brabandt <cb@256bit.org>
Problem: tabpanel may flicker in the GUI
Solution: call scroll_start() and scroll_region_reset()
(Hirohito Higashi)
fixes: #17440closes: #17442
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>