Problem:
Can't use `:source` to run a Lua codeblock (treesitter injection) in
a help (vimdoc) file.
Solution:
Use treesitter to parse the range and treat it as Lua if detected as
such.
Usually 'langmap' is used to map keyboard characters to ASCII motions or
mappings. It's not entirely clear what the purpose of mapping to Unicode
characters is, but since there is no error for mapping between two chars
both >= 256, only give a warning that this will not work properly when
mapping from a char < 256 to a char >= 256.
Omitting replace_keycodes when it is false causes some confusion as its
default value is unclear. In nvim_set_keymap() it defaults to false, but
in vim.keymap.set() it defaults to true when it matters.
Problem: Division by zero in :file after failing to wipe buffer
(after 8.2.4631).
Solution: Still call buf_clear_file() when failing to wipe buffer
(zeertzjq).
closes: vim/vim#190881aa5ca4ecb
Problem: :edit and :enew may reuse a 1-line terminal buffer, causing
the new buffer to still be a terminal buffer.
Solution: Don't reuse a terminal buffer, as it's not reused when it has
more than 1 line.
After this change close_buffer() is the only place where buf_freeall()
can be called on a terminal buffer, so move the buf_close_terminal()
call into buf_freeall() to save some code. Furthermore, closing the
terminal in buf_freeall() is probably more correct anyway, as it is
"things allocated for a buffer that are related to the file".
Also, remove the useless check for on_detach callbacks deleting buffer.
Even if b_locked fails to prevent that, the crash will happen at the end
of buf_updates_unload() first. On the other hand, many other call sites
of buf_updates_unload() and other buffer_updates_* functions don't set
b_locked, which may be a problem as well...
Problem: Crash when deleting terminal buffer and TermClose switches
back to the terminal buffer.
Solution: Set b_locked_split.
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Problem: printf format not checked for semsg().
Solution: Add GNUC attribute and fix reported problems. (Dominique Pelle,
closesvim/vim#3805)
b5443cc46d
Cherry-pick a change from patch 8.2.3830.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Calling termopen() or nvim_open_term() on a buffer with an
existing terminal leads to two terminals writing to the same
buffer if the terminal job is still running, or memory leak
if the terminal job has exited.
Solution: Close the terminal if the terminal job has exited, otherwise
report an error. For nvim_open_term() also don't write a
closed terminal's buffer content to the PTY.
Problem: Crash when closing a split window if autocmds close other
split windows but there are still floating windows.
Solution: Bail out and give the window back its buffer.
In close_buffer(), free_buffer() is called to remove the buffer from
buffer_handles immediately after removing it from the buffer list, so as
long as a buffer is in buffer_handles it is always valid.
Problem: Crash when a terminal receives OSC 2 just after closing its
buffer but before terminal job exits.
Solution: Remove FUNC_ATTR_NONNULL_ALL from buf_set_term_title() and
check for NULL.
Problem: Destroying a terminal with pending TermRequest leads to
heap-use-after-free when processing TermRequest afterwards.
Solution: Store the buffer handle instead of the Terminal pointer in the
pending TermRequest event, and don't emit TermRequest if the
terminal is already closed.
Problem: null pointer member access when closing the only non-float in the
current tab page if autocommands after closing all floats also close all other
tab pages. (making it the last window)
Solution: check last_window again after closing the floats.
Also reduce the scope of "wp"; it would be bugprone to use it before it's later
reassigned to the rv of win_free_mem if freed by Buf/WinLeave.
Add documentation notes explaining that visual marks '< and '> have
different behaviors in getpos() and setpos().
Also fix a small typo.
closes: vim/vim#1907093eb081eee
Co-authored-by: Larson, Eric <numeric.larson@gmail.com>
Problem: When switching to another terminal buffer in Terminal mode,
usually Nvim stays in Terminal mode, but leaves Terminal mode
if the old terminal buffer was deleted.
Solution: Don't always leave Terminal mode when active terminal buffer
is deleted. Instead let terminal_check_focus() decide that.
Problem: Inefficient use of ga_concat()
Solution: Use ga_concat_len() when the length is already known to avoid
use of strlen() (John Marriott).
Additionally the following changes are done:
os_unix.c:
- in function `socket_server_list_sockets()` use a `string_T` for the
strings `buf` and `path` for use in `ga_concat_len()`
and drop un-needed variable `dir`.
quickfix.c:
- in function `qf_jump_print_msg()` use a `string_T` for the string
`IObuff` for use in `ga_concat_len()`.
- in function `qf_range_text()` use a `string_T` for the string `buf`
for use in `ga_concat_len()`.
register.c:
- simplify function `execreg_line_continuation()`.
terminal.c:
- in function `read_dump_file()` use a `string_T` for the
string `prev_char` for use in `ga_concat_len()`.
tuple.c:
- in function `tuple_join_inner()` use a `string_T` for the
string `s` for use in `ga_concat_len()`. Also, change local struct
`join_T` to use `string_T`.
vim9type.c:
- in functions `type_name_tuple()` and `type_name_func()`
use a `string_T` for the string `arg_type` for use in
`ga_concat_len()`.
closes: vim/vim#19038a7e671fbb9
Skip tuple.
Co-authored-by: John Marriott <basilisk@internode.on.net>
Problem: :tlnumenu incorrectly accepts a range.
Solution: Remove EX_RANGE and EX_ZEROR from the command definition and
use ADDR_NONE (Doug Kearns).
closes: vim/vim#1905519442ad118
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
With `overlap=true`, more extmarks than the requested limit may be
collected in `extmark_get`. This then leads to an out of bounds write of
`rv` in `nvim_buf_get_extmarks`.
Work on #37166
- Dynamic Registration Tracking via Provider
- Supports_Method
- Multiple Registrations
- RegistrationOptions may dictate support for a method
vim-patch:9.0.0993: display errors when adding or removing text property type
vim-patch:7a6d9454c README.md: remove the warp ad again
vim-patch:9.1.2032: Vim9: error when using class member in Lambda
vim-patch:9.1.2036: if_ruby: build error with ruby 4.0
Problem: Cursor displayed in wrong position after deleting line.
Solution: When deleting lines do not approximate botline. (fixesvim/vim#8559)
5bea41dea3
Co-authored-by: Bram Moolenaar <Bram@vim.org>
vim-patch:9.1.2018: proto: ops.pro outdated
vim-patch:08aaa7ae1 runtime(doc): remove some fixed items from todo.txt
vim-patch:ea2b98b9e runtime(indent-tests): Include a simple Rust indent test
vim-patch:9.1.2031: Makefile: cannot run make installinks twice
vim-patch:8.2.0827: Vim9: crash in :defcompile
vim-patch:8.2.1643: Vim9: :defcompile compiles dead functions
vim-patch:8.2.1750: popup_setoptions() setting firstline fails if cursorline set
vim-patch:8.2.4947: text properties not adjusted when accepting spell suggestion
vim-patch:8.2.4989: cannot specify a function name for :defcompile
vim-patch:8.2.4990: memory leak when :defcompile fails
vim-patch:9.0.0147: cursor positioned wrong after two "below" text properties
vim-patch:9.0.0168: cursor positioned wrong with two virtual text properties
vim-patch:9.0.0233: removing multiple text properties takes many calls
vim-patch:9.0.0243: text properties "below" sort differently on MS-Windows
vim-patch:9.0.0464: with virtual text "above" indenting doesn't work well
vim-patch:9.0.0466: virtual text wrong after adding line break after line
vim-patch:9.1.0020: Vim9: cannot compile all methods in a class
vim-patch:9.1.0189: Memory leak with "above" virttext and 'relativenumber'
vim-patch:9.1.1654: build failure when FEAT_DIFF is not defined
vim-patch:9.1.1925: make depend does not include osdef.h
Problem:
We want to encourage implementing core features in Lua instead of C, but
it's clumsy because:
- Core Lua code (built into `nvim` so it is available even if VIMRUNTIME
is missing/invalid) requires manually updating CMakeLists.txt, or
stuffing it into `_editor.lua`.
- Core Lua modules are not organized similar to C modules, `_editor.lua`
is getting too big.
Solution:
- Introduce `_core/` where core Lua code can live. All Lua modules added
there will automatically be included as bytecode in the `nvim` binary.
- Move these core modules into `_core/*`:
```
_defaults.lua
_editor.lua
_options.lua
_system.lua
shared.lua
```
TODO:
- Move `_extui/ => _core/ui2/`
Problem:
Terminals should respond with the terminator (either BEL or ST) used in
the query so that clients can reliably parse the responses. The
`TermRequest` autocmd used to handle background color requests in the
terminal does not have access to the original sequence terminator, so it
always uses BEL. #37018
Solution:
Update vterm parsing to include the terminator type, then forward this
data into the emitted `TermRequest` events for OSC/DCS/APC sequences.
Update the foreground/background `TermRequest` callback to use the same
terminator as the original request.
Details:
I didn't add the terminator to the `TermResponse` event. However, I
assume the `TermResponse` event doesn't care about the terminator
because the sequence is already parsed. I also didn't update any of the
functions in `src/nvim/vterm/state.c` that write out responses. It
looked like those all pretty much used ST, and it would be a much larger
set of changes. In that same file, there's also logic for 8 bit ST
sequences, but from what I can tell, 8 bit doesn't really work (see `:h
xterm-8bit`), so I didn't use the 8 bit ST at all.
Problem: inefficient use of ga_concat()
Solution: Use ga_concat_len() when length is known.
(John Marriott)
closes: vim/vim#1902732b801abc3
Co-authored-by: John Marriott <basilisk@internode.on.net>
Problem: Exe stack length can be wrong without being detected.
Solution: Add a check when ABORT_ON_INTERNAL_ERROR is defined.
e31ee86859
vim-patch:8.2.3262: build failure when ABORT_ON_INTERNAL_ERROR is defined
Port patch 9.0.1454 for "make formatc".
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Buffer overflow in buf_write() when converting incomplete
multi-byte characters (Kevin Goodsell)
Solution: Make the buffer slightly larger
closes: vim/vim#19007f99de42a9f
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: 'fsync' option cannot be set per buffer
Solution: Make 'fsync' option global-local
(glepnir)
closes: vim/vim#190194d5b303726
Co-authored-by: glepnir <glephunter@gmail.com>
Problem: When virtualedit is set to all, the cursor is supposed to be
permitted to reside anywhere, including on the virtual space
beyond the end of the buffer's text. Switching modes triggered
a routine that "fixed" a cursor that was past the end of the
line by shifting it back to the last actual character in the
line and compensating with a virtual column offset. While
visually identical, this re-encoding changed the underlying
byte index, causing position-reporting functions to return
inconsistent values after a mode change.
Solution: Skip this coordinate adjustment when virtual editing is fully
enabled. By treating the line terminator as a valid, stable
position, the cursor’s internal representation remains
unchanged when entering or exiting Visual mode, ensuring
consistent coordinate reporting. Add a regression test to
check this functionality.
(McAuley Penney)
fixes: vim/vim#16276closes: vim/vim#19009491f0fa457
Co-authored-by: McAuley Penney <jacobmpenney@gmail.com>
fix(pum): hide info window when insufficient space
Problem:
1. Info window was displayed even with insufficient space.
2. Tab characters counted as single cells.
Solution:
1. Hide window when space < 10 columns. Will be configurable
via completepopup width option in the future.
2. Use win_linetabsize over mb_string2cells.
Problem: Substitute that joins lines drops text properties.
Solution: Move text properties of the last line to the new line.
213bbaf15a
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem:
When the popupmenu has no border but includes a scrollbar, the info window
column is misaligned due to a missing column offset.
Solution:
Apply a one-column offset to the info window when the popup menu has no border
and a scrollbar is present.
Problem: not possible to translation position in buffer
Solution: use _() macro to mark the output as translatable
(Emir SARI)
Row/Column indicator separator is currently not customizable. Some
languages have a space after the comma as the usual practice, plus this
would help translators use a custom separator like colons if necessary.
Additionally, after a save, the line and the byte indicator is also
hardcoded, this enables i18n for that as well.
closes: vim/vim#1760881f9815831
Co-authored-by: Emir SARI <emir_sari@icloud.com>
vim-patch:8.2.3793: using "g:Func" as a funcref does not work in script context
vim-patch:6ec7d40b7 runtime(getscript): GLVS plugin fails with wget.exe with PowerShell
vim-patch:2387c49f6 translation(zh_CN): Add license disclaimer
vim-patch:9.1.2002: Vim9: heap-use-after-free when when accessing protect class member
vim-patch:9.1.2010: Missing out-of-memory checks in vim9class.c
vim-patch:9.1.2011: crash when unreferencing gtk icon theme
Applicable patches became N/A due to previous ports (a4ea6027) and vim9:
vim-patch:8.2.0335: no completion for :disassemble
vim-patch:8.2.2033: Vim9: :def without argument gives compilation error
vim-patch:8.2.4288: preprocessor indents are inconsistent
vim-patch:8.2.4324: Vim9: script-local function name can start with "_"
vim-patch:8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
vim-patch:8.2.4957: text properties in a wrong position after a block change
vim-patch:9.0.0166: when using text properties line text length computed twice
vim-patch:9.0.0219: cannot make a funcref with "s:func" in a def function
vim-patch:9.0.1357: using null_object results in an internal error
vim-patch:9.0.1484: Coverity warns for using invalid array index
vim-patch:9.1.0274: MS-Windows: a few compiler warnings
vim-patch:9.1.1339: missing out-of-memory checks for enc_to_utf16()/utf16_to_enc()
vim-patch:9.1.1434: MS-Windows: missing out-of-memory checks in os_win32.c
Problem: ml_get_buf_len() does not consider text properties
(zeertzj)
Solution: Store text length excluding text properties length
in addition in the memline
related vim/vim#14123closes: vim/vim#14133a72d1be5a9
--------
Replace ml_line_len with ml_line_textlen to be explicit
that Nvim doesn't currently support Vim's text properties
and Nvim doesn't support lines with "ambiguous" length.
--------
vim-patch:9.1.0153: Text properties corrupted with fo+=aw and backspace
Problem: Text properties corrupted with fo+=aw and backspace
Solution: Allocate line and move text properties
(zeertzjq)
closes: vim/vim#141477ac1145fbe
vim-patch:9.1.0163: Calling STRLEN() to compute ml_line_textlen when not needed
Problem: Calling STRLEN() to compute ml_line_textlen when not needed.
Solution: Use 0 when STRLEN() will be required and call STRLEN() later.
(zeertzjq)
closes: vim/vim#1415582e079df81
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Problem: patterns after a buffer-local pattern in a comma-separated aupat are
ignored.
Solution: ensure pat refers to the original buffer after each pattern, not the
buflocal_pat buffer, and when printing make sure it's normalized for
each pattern, not just the first.
Also simplify the logic when printing all autocommands for an event, and ensure
headings aren't repeated for each event when printing autocommands.
Problem: typo in change of commit v9.1.0873
(Christ van Willegen)
Solution: Add back the square brackets
(John Marriott)
closes: vim/vim#16340df4b3ca5dc
Co-authored-by: John Marriott <basilisk@internode.on.net>