Commit Graph

6 Commits

Author SHA1 Message Date
Matthew Malcomson
dfb676fe0d edit.c: Ensure undo sync when emulating <Esc>x #11706
After PR #8226 an unmapped META key in insert mode behaves like
ESC-<key> (:help i_META).

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`.

- Fix by calling u_sync() manually in the new clause under
  `normalchar:` in `insert_handle_key`.
- Update test in tui_spec.lua that accidentally relied on the old behaviour.
2020-01-12 17:09:39 -08:00
Björn Linse
e50aa2a6c6 normal: Don't exit CTRL-O mode after processing K_EVENT 2019-06-04 13:59:43 +02:00
Justin M. Keyes
224ebc0078 insert-mode: interpret unmapped META as ESC
closes #2454
closes #8213
ref #7972
2018-04-04 03:23:15 +02:00
d10n
69e9cda5ac i_CTRL-O: fix :startinsert at end of line (#6963)
The gchar_cursor() == NUL check is already done in ins_ctrl_o.
ins_esc changes gchar_cursor() so this if block is probably never
entered.

Issue:

Pressing CTRL-O in insert mode at the end of the line and typing
:startinsert moves the cursor 1 column back, when I expect the cursor
to remain at the end of the line

This is a regression from Vim behavior. Since at least Vim version 7.0,
Vim returns you to insert mode at the end of the line.

091e7d033c is the first bad neovim commit

Steps to reproduce using `nvim -u NORC`:
`aaaa<C-o>:startinsert<CR>`

Fixes #6962
2017-07-08 12:50:58 +02:00
Björn Linse
12fc1defd6 ops: fix i<c-r> with multi-byte text (#6524) 2017-04-15 11:19:40 +02:00
Matthew Malcomson
86c2adc074 edit.c: CTRL-SPC: Insert previously-inserted text. #6090
Default Vim behavior of i_CTRL-<Space> is to insert the last-inserted
text and exit insert mode. :help i_CTRL-@

Before this commit that did not happen because insert_handle_key()
checks for NUL instead of checking for ' ' with a CTRL `mod_mask`.

I'm leaving the check for NUL despite the fact that at the moment that
key is never seen when using the terminal UI (not for C-Space, nor C-@).
This is because I assume it's still allowed for other front-ends to pass
NUL, but at the moment the terminal UI isn't.
2017-02-28 01:16:18 +01:00