Commit Graph

57 Commits

Author SHA1 Message Date
zeertzjq
0451391ec5
fix(mark): properly init mark views (#22996) 2023-04-10 22:49:32 +08:00
zeertzjq
73060f00dd
test: improve editor/fold_spec.lua and editor/put_spec.lua (#22916)
- Close and open a new window each time so that window options have
  their default values in each test.
- Change feed_command() to command() as the latter is faster.
2023-04-07 09:29:12 +08:00
Brandon Simmons
824639c7c1
fix(folds): handle visual blockwise indent insertion correctly (#22898)
Previously, the fold information was incorrect because it wasn't
being updated during the blockwise insertion.
(Solution by zeertzjq)
2023-04-07 00:08:46 +08:00
zeertzjq
4eef5ac453
vim-patch:9.0.1428: cursor in wrong position when leaving insert mode (#22786)
Problem:    Cursor in wrong position when leaving insert mode.
Solution:   Update the w_valid flags.  Position the cursor also when not
            redrawing. (closes vim/vim#12137)

c174c2e58c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-03-26 09:24:04 +08:00
Evgeni Chasnovski
fe9cbcb3a5
feat(api): nvim_exec2(), deprecate nvim_exec() #19032
Problem:
The signature of nvim_exec() is not extensible per ":help api-contract".

Solution:
Introduce nvim_exec2() and deprecate nvim_exec().
2023-03-25 09:58:48 -07:00
zeertzjq
8065fc9aae
fix(edit): don't subtract msg_scrolled when removing double quote (#22630)
With msg_grid there is no need to subtract msg_scrolled.
2023-03-11 20:12:58 +08:00
zeertzjq
9b9f8dfcc4 test: make {MATCH:} behave less unexpectedly in screen:expect()
Include the rest of the line and allow multiple {MATCH:} patterns.
2023-02-18 10:44:35 +08:00
zeertzjq
d512678739 fix(completion): correct what modes support fuzzy completion 2023-01-17 15:55:58 +08:00
zeertzjq
61d5bd561a refactor: remove E5500, adjust tests
Now with try_end() including more exception info, E5500 looks like
redundant information.
Adjust tests for more exception information.
2023-01-16 18:03:08 +08:00
zeertzjq
95044991e6 test(undo_spec): add more tests for writing in Insert mode 2022-12-09 07:00:27 +08:00
zeertzjq
70d6c335b1 vim-patch:9.0.1036: undo misbehaves when writing from an insert mode mapping
Problem:    Undo misbehaves when writing from an insert mode mapping.
Solution:   Sync undo when writing. (closes vim/vim#11674)

3f8f827723

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-12-09 06:55:15 +08:00
zeertzjq
65e8ed45de
vim-patch:9.0.0969: matchparen highlight is not updated when switching buffers (#21227)
Problem:    Matchparen highlight is not updated when switching buffers.
Solution:   Listen to the BufLeave and the BufWinEnter autocmd events.
            (closes vim/vim#11626)

28a896f54d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2022-11-29 10:17:57 +08:00
zeertzjq
428ab6f24e
fix(mark): do not restore view in op-pending mode (#20889) 2022-11-01 06:14:20 +08:00
zeertzjq
a7d100f052
fix: avoid unsigned overflow in home_replace() (#20854) 2022-10-30 06:49:39 +08:00
zeertzjq
e6f7e038b8
fix(completion): set pum_size even if ext_popupmenu is used (#20648)
This allows CompleteChanged event to get the correct `v:event.size`.
It should be harmless and more consistent to also set `pum_array`.
2022-10-14 23:08:00 +08:00
zeertzjq
7a70e9587c
test(tabpage_spec): actually test for nvim_win_hide 2022-09-23 10:17:44 +08:00
zeertzjq
d7052e8e1f test: add tests for #13549 #20285 #20290 2022-09-23 07:38:22 +08:00
zeertzjq
b21980bd60
fix(keywordprg): default to :help if set to empty string (#19983) 2022-08-29 05:58:32 +08:00
Axel Forsman
d4d27c41b3
fix(edit.c): indentkeys double indent after "!" #12894
which is both unexpected and different from the Vim behaviour.

Indent was triggered once by the '!' check in insert_execute(), and
inserting the char was correctly skipped, but then triggered again in
insert_check() (provided that cindent was not being ignored after manual
indentation, i.e. `can_cindent == true`).

While this is the smallest fix, another solution would be to remove
VimState#check and instead move that to *_enter()/-_execute(), since the
control flow is pretty unnecessarily convoluted as is. That would also
have the benefit of differing less from the Vim source code.
2022-08-21 21:48:18 -07:00
zeertzjq
cf3b871fa9
test: use poke_eventloop() instead of sleep(10) where possible (#19794)
Using sleep(10) to wait for typeahead to finish is flaky, especially on
macOS, where legacy/global_spec.lua has failed several times.
2022-08-16 15:21:46 +08:00
zeertzjq
0a29267514
fix(completion): remove wrong FUNC_ATTR_NONNULL_ALL (#19627) 2022-08-03 21:50:14 +08:00
zeertzjq
c57e133e50
fix(ui): set redraw_cmdline when setting window height (#19630) 2022-08-03 19:25:03 +08:00
zeertzjq
def0ced4c7
fix(tabpage): check if ROWS_AVAIL changed for resize (#19620)
N/A patches for version.c:

vim-patch:9.0.0135: comment about tabpage line above the wrong code

Problem:    Comment about tabpage line above the wrong code.
Solution:   Move the comment. (closes vim/vim#10836)
0b0ccbbfb0
2022-08-02 20:48:41 +08:00
zeertzjq
eb77122823 fix(input): do no reinterpret mouse keys with ALT modifiers
Remove check for MOD_MASK_META as it is for <T- which never appears in TUI.
Make small changes to docs.
2022-07-25 09:47:28 +08:00
zeertzjq
c15e9d3746
fix(mark): give correct error message when mark is in another buffer (#19454) 2022-07-21 17:42:17 +08:00
bfredl
45bee1dafd perf(ui): eliminate spurious memory allocations for hl_attr_define event 2022-07-18 14:08:44 +02:00
zeertzjq
9ced054134
fix(mark): fix unexpected cursor movements (#19253) 2022-07-06 19:01:44 +08:00
zeertzjq
826fe56f5c
fix(mark): mark without a view restores at topline #19224
For a local mark without a view, currently trying to restore its view
will put the cursor at topline, which is not the correct behavior.
Initialize `topline_offset` to `MAXLNUM` instead to fix this.
2022-07-04 13:28:14 -07:00
Javier Lopez
565f72b968
feat(marks): restore viewport on jump #15831
** Refactor

Previously most functions used to "get" a mark returned a position,
changed the line number and sometimes changed even the current buffer.

Now functions return a {x}fmark_T making calling context aware whether
the mark is in another buffer without arcane casting. A new function is
provided for switching to the mark buffer and returning a flag style
Enum to convey what happen in the movement. If the cursor changed, line,
columns, if it changed buffer, etc.

The function to get named mark was split into multiple functions.

- mark_get() -> fmark_T
- mark_get_global() -> xfmark_T
- mark_get_local() -> fmark_T
  - mark_get_motion() -> fmark_T
  - mark_get_visual() -> fmark_T

Functions that manage the changelist and jumplist were also modified to
return mark types.

- get_jumplist -> fmark_T
- get_changelist -> fmark_T

The refactor is also seen mainly on normal.c, where all the mark
movement has been siphoned through one function nv_gomark, while the
other functions handle getting the mark and setting their movement
flags. To handle whether context marks should be left, etc.

** Mark View

While doing the refactor the concept of a mark view was also
implemented:

The view of a mark currently implemented as the number of lines between
the mark position on creation and the window topline. This allows for
moving not only back to the position of a mark but having the window
look similar to when the mark was defined. This is done by carrying and
extra element in the fmark_T struct, which can be extended later to also
restore horizontal shift.

*** User space features

1. There's a new option, jumpoptions+=view enables the mark view restoring
automatically when using the jumplist, changelist, alternate-file and
mark motions. <C-O> <C-I> g; g, <C-^> '[mark] `[mark]

** Limitations

- The view information is not saved in shada.
- Calls to get_mark should copy the value in the pointer since we are
  using pos_to_mark() to wrap and provide a homogeneous interfaces. This
  was also a limitation in the previous state of things.
2022-06-30 05:59:52 -07:00
zeertzjq
e15d31b530
fix(input): fix macro recording with ALT and special key (#18917) 2022-06-10 17:13:57 +08:00
zeertzjq
9e442c17ee
fix(input): allow Ctrl-C to interrupt a recursive mapping even if mapped (#18885) 2022-06-07 12:41:18 +08:00
Gregory Anders
9e1ee9fb1d
refactor!: delete insertmode (#18547)
Neovim already removed `evim` (or any similar flags). The 'insertmode'
option is a weird remnant, so get rid of it.

The 'insertmode' option is replaced with a script that closely emulates
the option. This script is documented at :help 'insertmode'
2022-05-22 21:20:18 -06:00
Marco Hinz
8fba428bc6
fix(cmd): make :-tabmove work with modifiers (#18447)
`:tabmove` takes either an argument (`:tabmove -`) or an address (`:-tabmove`).

The code assumed that `:tabmove` is the first command on the cmdline, but that
is not the case when using additional modifiers like `:silent`.

Make the addr parsing more robust by searching the command first, then going
back to check for a potential address `-`.
2022-05-12 16:43:20 +02:00
zeertzjq
d531ef6813 vim-patch:8.2.0867: using \{xxx} for encoding a modifier is not nice
Problem:    Using \{xxx} for encoding a modifier is not nice.
Solution:   Use \<*xxx> instead, since it's the same as \<xxx> but producing a
            different code.
fccd93f091

Use this notation in langmap_spec.
2022-04-29 15:51:04 +08:00
zeertzjq
212349c100 feat(edit): insert an unsimplified key using CTRL-SHIFT-V
This marks the following Vim patches as ported:

vim-patch:8.1.2333: with modifyOtherKeys CTRL-^ doesn't work

Problem:    With modifyOtherKeys CTRL-^ doesn't work.
Solution:   Handle the exception.
828ffd5963

vim-patch:8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys

Problem:    Other text for CTRL-V in Insert mode with modifyOtherKeys.
Solution:   Convert the Escape sequence back to key as if modifyOtherKeys is
            not set, and use CTRL-SHIFT-V to get the Escape sequence itself.
            (closes vim/vim#5254)
fc4ea2a72d

vim-patch:8.2.2084: CTRL-V U doesn't work to enter a Unicode character

Problem:    CTRL-V U doesn't work to enter a Unicode character when
            modifyOtherKeys is effective. (Ken Takata)
Solution:   Add a flag to get_literal() for the shift key. (closes vim/vim#7413)
0684e36a7e

Omit getcmdkeycmd() change as it depends on Vim patch 8.2.2062, which
may introduce a potential breakage.
2022-04-29 15:51:03 +08:00
zeertzjq
519e4c4472 test: correct order of arguments to eq() and neq() 2022-04-26 11:38:58 +08:00
Famiu Haque
1e3d9c7dbc feat: add undo!
Allows using `undo!` to undo changes and remove them from the undo-tree. Can only be used for moving backwards in the same undo branch.
2022-04-20 00:10:02 +06:00
zeertzjq
b099bb1f2f test: add a test for #16823 2022-04-08 19:25:37 +08:00
zeertzjq
64802da6c4 fix(event-loop): check if executed register has ended 2022-04-07 21:42:11 +08:00
zeertzjq
2a574f7aaa fix(input): fix clearing of reg_executing
vim-patch:8.2.4705
2022-04-07 21:42:07 +08:00
zeertzjq
c41e75039f
test: move completion :stopinsert test to completion_spec.lua (#17992) 2022-04-04 14:53:47 +08:00
zeertzjq
ae0a43ec23 fix(tabpage): correct check for failure to close window
Avoid closing window 999 times.
2022-03-27 10:01:35 +08:00
zeertzjq
a80ec88906 test: add a test for #17489 2022-03-10 17:22:39 +08:00
dundargoc
a7b1c8893c
chore: fix typos (#17331)
Co-authored-by: Hongyi Lyu <hongyi.lyu95@gmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: notomo <notomo.motono@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-03-10 14:34:55 +08:00
zeertzjq
d9cb3fba92 vim-patch:8.2.4242: put in Visual mode cannot be repeated
Problem:    Put in Visual mode cannot be repeated.
Solution:   Use "P" to put without yanking the deleted text into the unnamed
            register. (Shougo Matsushita, closes vim/vim#9591)
fb55207ed1

Cherry-pick get_y_previous() and set_y_previous() from patch 8.1.1736.
Nvim has removed y_current, so code related to it is N/A.
2022-02-09 14:21:04 +08:00
zeertzjq
75f4741db9 fix(input): remove reinterpreted ALT/META chords from recorded macro 2022-01-29 06:05:14 +08:00
zeertzjq
95873aa3eb test: add more tests for Insert mode Ctrl-V 2022-01-25 08:29:04 +08:00
zeertzjq
0efe1ec6b3 test(input): add more tests for K_SPECIAL escaping in ins_char_typebuf() 2022-01-23 05:58:32 +08:00
zeertzjq
431915fe6a
test(put_spec): correctly order parameters to eq() (#17134)
The first parameter to eq() should be the expected value, and the second
parameter should be the actual value.
2022-01-19 13:53:39 -07:00
Daniel Steinberg
3ee1ba35a7
fix(keywordprg): retain terminal buffer after K (#17046) 2022-01-12 22:04:30 -07:00