Skip to content

Conversation

hardenedapple
Copy link
Contributor

@hardenedapple hardenedapple commented Jan 12, 2020

After PR #8226 an unmapped META key in insert mode behaves as <Esc>-<key>.

The behaviour does not fully match, since if <Esc>-<key> is pressed
manually then since it were pressed manually gotchars would be called
on the second <key> after insert-mode had already been left.

This would mean that may_sync_undo (called from gotchars) would
call u_sync(FALSE) on the second key (since we would be in normal
mode).

This overall means that <Meta-[something]> behaves differently with
respect to undo than <Esc>[something] when the [something] makes a
change.

As an example, under nvim -u NONE.

ihello<M-.>u

Leaves the buffer empty, while

ihello<Esc>.u

Leaves the buffer with one instance of hello.

This patch fixes that by calling u_sync() manually in the new clause
under normalchar: in insert_handle_key.

I also include a new test, and change a test in tui_spec.lua that relies
on the old behaviour.

The test in tui_spec.lua looks to not be testing for this behaviour, but
just testing it by side-effect (i.e. I don't believe this behaviour was
intentionally checked in that file).

After PR neovim#8226 an unmapped META key in insert mode behaves as Esc-<key>.

The behaviour does not fully match, since if <Esc>-<key> is pressed
manually then since it were pressed manually `gotchars` would be called
on the second <key> after insert-mode had already been left.

This would mean that `may_sync_undo` (called from `gotchars`) would
call `u_sync(FALSE)` on the second key (since we would be in normal
mode).

This overall means that <Meta-[something]> behaves differently with
respect to undo than <Esc>[something] when the [something] makes a
change.

As an example, under `nvim -u NONE`.
ihello<M-.>u

Leaves the buffer empty, while
ihello<Esc>.u

Leaves the buffer with one instance of `hello`.

This patch fixes that by calling u_sync() manually in the new clause
under `normalchar:` in `insert_handle_key`.

I also include a new test, and change a test in tui_spec.lua that relies
on the old behaviour.

The test in tui_spec.lua looks to not be testing for this behaviour, but
just testing it by side-effect (i.e. I don't believe this behaviour was
intentionally checked in that file).
@justinmk justinmk added this to the 0.5 milestone Jan 13, 2020
@justinmk justinmk added input core Nvim core functionality or code labels Jan 13, 2020
@justinmk justinmk merged commit dfb676f into neovim:master Jan 13, 2020
@justinmk
Copy link
Member

justinmk commented Jan 13, 2020

Thank you very much!

BTW, I would like to merge #6494 soon. In case you have some time to rebase merge / sanity-check it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Nvim core functionality or code input
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants