Commit Graph

67 Commits

Author SHA1 Message Date
zeertzjq
d432bba4e4
fix(marks): handle switching buffer properly (#25763) 2023-10-24 16:10:36 +08:00
glepnir
ae4ca4edf8 feat(complete): support f flag for complete buffer part 2023-10-21 20:06:36 +08:00
zeertzjq
9f32deba56
fix(grid): add start column when getting char on line (#25627) 2023-10-13 21:43:06 +08:00
zeertzjq
01c51a4913 feat(completion): support completing more string options 2023-10-01 20:00:23 +08:00
zeertzjq
b65f4151d9
vim-patch:8.2.3517: TextChanged does not trigger after TextChangedI (#25384)
Problem:    TextChanged does not trigger after TextChangedI.
Solution:   Store the tick separately for TextChangedI. (Christian Brabandt,
            closes vim/vim#8968, closes vim/vim#8932)

db3b44640d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-27 18:51:40 +08:00
Brandon Simmons
58f9486144
fix(folds): update folds in Insert mode with fdm=indent (#24402)
Previously, when using foldmethod=indent, inserting an unindented line
would inadvertently open closed folds below it.
As a performance improvement, folds were only updated once, across all
lines, after Insert mode was exited.

Now, the performance improvement is no longer being used when
foldmethod=indent, so folds are updated multiple times during Insert
mode, but only across the lines that are changing, which preserves the
folds (and their open/close states) instead of recreating them.
2023-07-21 08:56:08 +08:00
Alexandre Teoi
a741c7fd04
fix(api): nvim_parse_cmd error message in pcall() #23297
Problem:
nvim_parse_cmd() in pcall() may show an error message (side-effect):

    :lua pcall(vim.api.nvim_parse_cmd, vim.fn.getcmdline(), {})
    E16: Invalid range

Solution:
Avoid emsg() in the nvim_parse_cmd() codepath.

- refactor(api): add error message output parameter to get_address()
- fix: null check emsg() parameter
- refactor: remove emsg_off workaround from do_incsearch_highlighting()
- refactor: remove emsg_off workaround from cmdpreview_may_show()
- refactor: remove remaining calls to emsg() from parse_cmd_address() and get_address()
- (refactor): lint set_cmd_dflall_range()
- refactor: addr_error() - move output parameter to return value

Fix #20339

TODO:

These are the functions called by `get_address()`:

```
nvim_parse_cmd() -> parse_cmdline() -> parse_cmd_address() -> get_address()
    skipwhite()
    addr_error()
    qf_get_cur_idx()
    qf_get_cur_valid_idx()
    qf_get_size()
    qf_get_valid_size()
    mark_get()
    mark_check()
    assert()
    skip_regexp()
    magic_isset()
>   do_search()
>   searchit()
    ascii_isdigit()
    getdigits()
    getdigits_int32()
    compute_buffer_local_count()
    hasFolding()
```

From these functions, I found at least two that call emsg directly:
- do_search()
  - seems to be simple to refactor
- searchit()
  - will be more challenging because it may generate multiple error messages,
    which can't be handled by the current `errormsg` out-parameter.
    For example, it makes multiple calls to `vim_regexec_multi()` in a loop that
    possibly generate error messages, and later `searchit()` itself may generate
    another one:
    - c194acbfc4/src/nvim/search.c (L631-L647)
    - c194acbfc4/src/nvim/search.c (L939-L954)

---------

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-01 06:33:51 -07: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
zeertzjq
75119fcc86 vim-patch:8.2.3135: Vim9: builtin function arguments not checked at compile time
Problem:    Vim9: builtin function arguments not checked at compile time.
Solution:   Add more type checks. (Yegappan Lakshmanan, closes vim/vim#8539)

5b73992d8f

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-05-05 09:19:05 +08:00
zeertzjq
d321deb4a9
test: fix dependencies between test cases (#23343)
Discovered using --shuffle argument of busted.
2023-04-27 15:51:44 +08:00
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