Historically, IdeaVim was starting read or write action based on command type. However, this is incorrect because of several reasons:
- The command of different type may perform a write/read action
- The write lock with a lot of code inside does cause application freezes
- Since a large branching of code happens inside the write action, there is a chance of read action request, resulting in the deadlock
Also, now this prevents from implementing a proper execution of VIM-3376.
It's not clear why the write action was needed. Probably, it was a mistake and it supposed to be a check for EDT. However, since the check for EDT exists right in the constructor of the potemkin progress, let's remove it at all.
Adds extra tests to confirm that deleting previous word in Insert mode was already working as expected (relates to VIM-1650)
Also fixes an edge case for a test that was marked as behaving differently to Vim, but was actually showing buggy behaviour due to its unorthodox caret placement. It looked like the caret was placed at the end of the line, but it was actually placed _passed_ the last character in the file. Adding extra text below the caret placement would cause the action to behave as expected, and the test would then match Vim behaviour. However, it is possible to get this caret position in the editor and in Vim, with `virtualedit=onemore`, and the IdeaVim implementation was wrong. The test has been updated to provide the correct scenario, and the implementation has been fixed.
This is needed for the new terminal. Before this change, it was impossible to put the caret at the line end, even taking the fact the IdeaVim is disabled in the new terminal.
Simplify and reorganize logic in isEnabled() for improved readability and maintainability. Adjust logging messages for consistency and replace unused exception variable with underscore.
As the GitHub Copilot is placed right in the editor component, the IdeaVim's actions are also collected. Action promoter promotes the IdeaVim's action and, since the data context has the editor, executes a Vim's actions like backspace.
Now we make sure that IdeaVim works only in the actual editor.
Since this change may affect some places where the IdeaVim used to work, but won't work now (this will be a surprise), a registry key is introduced to help the users that face this problem.
The `editorInFocus` used the weak reference in order to avoid editor leaks. However, if the user is unlucky, the GC may be called in between the console closing and switching focus to the new editor. In this case, the logic breaks and the Editor remains in the insert mode.
Now, we store only the required information about the last used editor.
This commit fixes 2 bugs at once:
1. Correctly trim surround with closing brackets motion, e.g.: `cs()`.
It should trim all surrounding white space or leave things unchanged if
there's no space.
For example cases like these:
"( ${c}foo )" // single spaces
"( ${c}foo )" // multiple spaces
"( ${c}foo)" // assymetric spaces
"(${c} )" // single space without text
"(${c} )" // multiple spaces without text
Should trim white spaces into these results accordingly:
"${c}(foo)"
"${c}(foo)"
"${c}(foo)"
"${c}()"
"${c}()"
In case of no spaces - they should be left unchanged, e.g.:
"(${c}foo)" // no spaces around the word
"(${c})" // empty parenthesis
2. Leave empty parenthesis unchanged. IdeaVim now deleted them instead.
**Context**:
In vim surround extendsion closing brackets (`}, ], )`) should remove
whitespace when using `cs` movement.
Example:
- Before: `{ example }`
- Movement: `cs{}`
- After: `{example}`
This was because were replaced with a string from `SURROUND_PAIRS` map,
which does not have any context about removing characters.
**Solution**:
Inspired from VSCode's VIM plugin[^1], I have introduced new class
`SurroundPair` that will carry this context about need to trim
characters.
**Disclaimer**:
I have never written in `Kotlin` so solution may be not use best
practices, though at least this PR seems to fix the problem and tests
are passing.
**Ticket**:
- https://youtrack.jetbrains.com/issue/VIM-1824/Vim-Surround-Does-not-remove-whitespace-with-the-closing-bracket
[^1]: 04fe42aa81/src/actions/plugins/surround.ts (L455)