Commit Graph

10 Commits

Author SHA1 Message Date
zeertzjq
ef44e59729
fix(inccommand): don't set an invalid 'undolevels' value (#24575)
Problem:    Cannot break undo by setting 'undolevels' to itself in
            'inccommand' preview callback.
Solution:   Don't set an invalid 'undolevels' value.

Co-authored-by: Michael Henry <drmikehenry@drmikehenry.com>
2023-08-05 22:42:34 +08:00
zeertzjq
14d047ad2f
test(inccommand): add a test for #20248 (#24489) 2023-07-26 11:58:26 +08:00
Alexandre Teoi
643bea31b8
fix(inccommand): restrict cmdpreview undo calls (#24289)
Problem:
The cmdpreview saved undo nodes on cmdpreview_prepare() from ex_getln.c may
become invalid (free) if the preview function makes undo operations, causing
heap-use-after-free errors.

Solution:
Save the buffer undo list on cmdpreview_prepare)_ and start a new empty one. On
cmdpreview_restore_state(), undo all the entries in the new undo list and
restore the original one. With this approach, the preview function will be
allowed to undo only its own changes.

Fix #20036
Fix #20248
2023-07-26 11:22:57 +08:00
zeertzjq
9dd48f7832
fix(substitute): properly check if preview is needed (#23809) 2023-05-29 08:44:52 +08:00
Lewis Russell
1fe1bb084d refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-05-21 15:14:01 +06:00
dundargoc
df646572c5
docs: fix typos (#20394)
Co-authored-by: Raphael <glephunter@gmail.com>
Co-authored-by: smjonas <jonas.strittmatter@gmx.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-30 09:53:52 +02:00
Famiu Haque
c2f7a2a18d feat: multibuffer preview support for inccommand
Allows preview callbacks to modify multiple buffers in order to show the
preview. Previously, if multiple buffers were modified, only the current
buffer would have its state restored. After this change, all buffers
have their state restored after preview.

Closes #19103.
2022-08-19 09:27:52 +06:00
zeertzjq
57a296d899
fix(inccommand): avoid crash if callback changes inccommand option (#18830)
clang: Result of operation is garbage or undefined
clang: Uninitialized argument value

Also check for == 's' instead of != 'n' as it is more straightforward.

Also fix another unrelated PVS warning:
PVS/V1071: Return value of win_comp_pos() is not always used
2022-06-02 03:48:36 +08:00
zeertzjq
f40adf770d
fix(inccommand): do not try to preview an ambiguous command (#18827) 2022-06-01 20:17:52 +08:00
Famiu Haque
46536f53e8 feat: add preview functionality to user commands
Adds a Lua-only `preview` flag to user commands which allows the command to be incrementally previewed like `:substitute` when 'inccommand' is set.
2022-05-31 20:55:05 +06:00