Commit Graph
5146 Commits
Author SHA1 Message Date
Alex Plate 36556d559f Optimize imports 2025-01-10 13:28:47 +03:00
Alex Plate ef16181ba2 Clean up code 2025-01-10 13:28:46 +03:00
Alex Plate aaba0a09c2 Remove deprecated function 2025-01-10 13:28:46 +03:00
Matt EllisandAlex Pláte 0b308769b1 Move select toggle implementation 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte a28416dd9f Update mode widget text for Select pending 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte 63b3af3f65 Implement v_CTRL-O
From Select mode, enters Visual for a single command
2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte fcc234c4fe Rename submode to selectionType 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte 2e0ef7e0b0 Enter Insert Visual/Select mode with shifted key 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte da99e1f1c3 Return to Insert when leaving Insert Normal 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte 5827ad1581 Only show mode widget popup on left mouse click 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte 8b8ef80a5e Reinstate showmode tests 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte dc5ef487d2 Show additional Insert modes in showmode widget 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte eaad93903b Simplify Mode hierarchy
Wanting to add `ReturnTo.SELECT` would be very tricky, as we would have to recreate the mode, but have no details about the selection type.
2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte a6b2bf1c55 Remove ReturnableFromCmd marker interface 2025-01-10 11:29:44 +03:00
Matt EllisandAlex Pláte e3a07b6c89 Add support for CTRL-J
Supported in Normal, Visual, Select and Operator-pending. Also adds support for CTRL-M in Select mode.

Fixes VIM-3740
2025-01-10 10:00:28 +03:00
Xinhe Wangandlippfi bde4fcdd47 Fix test failure introduced in 5e60ea7 2024-12-21 20:29:18 +02:00
Alex Plate 69811c864e Add checks to avoid incorrect creation of the visual position
Related to VIM-3755
2024-12-18 16:33:18 +02:00
Alex Plate c225452432 [VIM-3577] Store the information if the editor was initialized in insert mode 2024-12-18 13:19:20 +02:00
Filipp Vakhitov 5e60ea7f4c Fix(VIM-3754): set clipboard+=unnamed stopped working in IdeVIM 2.18
I did remove `exclude:cons\\|linux` from the overriden value
2024-12-18 13:11:26 +02:00
Alex Plate 5995a48d7b [VIM-3577] Replace weak reference to focused editor to needed information
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.
2024-12-17 20:36:51 +02:00
Alex Plate 4614e2ad54 [VIM-3617] Remove the forgotten recursion call 2024-12-17 10:06:48 +02:00
Alex Plate 077de91e01 [VIM-3617] Set a recursion guard for obtaining the editor
Function `selectedTextEditor` in some cases may create a new editor, what causes the recursion and IDE freeze. The guard should protect from it.
2024-12-17 10:02:34 +02:00
Alex Plate 1ce7a97f2a Fix(VIM-3747): There is no need to remove the visual mode if there is still a selection 2024-12-16 13:38:29 +02:00
Julien PhalipandAlex Pláte 4962baabad Add support for hlsearch variable 2024-12-06 17:21:33 +02:00
Julien PhalipandAlex Pláte 2e550a0960 Add support for escape() vim function 2024-12-06 17:09:59 +02:00
Matt EllisandAlex Pláte a005eb0612 Fix repeating change action with count
Fixes VIM-3729
2024-12-04 18:23:16 +02:00
Justas TrimailovasandAlex Pláte 63297e685c Correctly change surround if it's empty or only spaces
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.
2024-12-04 18:07:02 +02:00
Justas TrimailovasandAlex Pláte 6c9a5e1f2d [VIM-1824] surround - remove whitespace with closing bracket
**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]: https://github.com/VSCodeVim/Vim/blob/04fe42aa815f638af14e4cf4c92e88109242c3e6/src/actions/plugins/surround.ts#L455
2024-12-04 18:07:02 +02:00
Julien Phalipandlippfi ec3db81c6d Move register variable to its own separate class 2024-11-26 10:32:11 +02:00
Julien Phalipandlippfi 7062dc4860 Add support for the v:register variable 2024-11-26 10:32:11 +02:00
Alex Plate 0f1a4d523f Move the docs to the init method of VimExtension 2024-11-25 14:01:23 +02:00
Alex Plate 5f5a97a7e1 Lazily load the logger to avoid injector initialization problems 2024-11-25 13:39:24 +02:00
filippandAlex Pláte 0dd63c7b57 Fix nullable editor in tests 2024-11-22 17:15:07 +02:00
filippandAlex Pláte 94d7902ef2 Remove more deprecated methods 2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte eae3fb3ebe Introduce VimKeyBasedUndoService and VimTimestampBasedUndoService
Undo is managed differently in Fleet and IJ Platform, so now we have two different interfaces that are aware of that
2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte 25e3988dcf Introduce VimCopiedText class
I don't really like that we have `transferableData: List<Any>`
2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte 36589c5250 Add context argument in clipboard methods
Alas, adding in just to clipboard was not possible, as there are a lot of depending on methods
2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte f1f86b5cd2 Simplify Register class
1. `rawText` vs `text` is confusing and `rawText` was misused, we do not need this field in IdeaVim at all
2. `rawText` and `keys` are the same thing, just parsed. And for some reason, rawText was a nullable field
3. Register is an immutable class now
4. Working with Register class is easier and more compact now
2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte 628b3ca89f Fix <CR> parsing
It's ^M, not ^J
2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte d2b929ddd0 Fix parsing for clipboard option
When I added the selection clipboard, it was confusing to explain to people how this option works and why they should prepend, because the parsing was broken
I've also removed "exclude" part, because it doesn't work in IdeaVim and can confuse people
2024-11-22 17:15:07 +02:00
filippandAlex Pláte 43d770ff5a Simplify getTransferableData method signature 2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte 66aec26091 Move ColLineFunctionHandler.kt to vim-engine 2024-11-22 17:15:07 +02:00
Filipp VakhitovandAlex Pláte 1d59c49b95 Move more logic to vim-engine 2024-11-22 17:15:07 +02:00
Matt EllisandAlex Pláte 8da15b8c08 Manually track last selected editor
This is important for initialising options. We can't rely on FileEditorManager.selectedTextEditor, as 2024.2 changed behaviour to reset to null during creation of a new editor. This fixes tests (and option initialisation) for 242.
2024-11-22 17:01:38 +02:00
Matt EllisandAlex Pláte e22c2b6473 Improve updating fallback window option values
The assumption for selection change events is no longer valid in 242, so switch approach to checking when editors are released
2024-11-22 17:01:38 +02:00
Matt EllisandAlex Pláte e293c1b786 Add tests for updating the fallback window 2024-11-22 17:01:38 +02:00
Matt EllisandAlex Pláte 468ca840ed Update options tests
Expanded to assert changes on all open windows, and formatted to make it a little easier to read/comprehend what's being tested
2024-11-22 17:01:38 +02:00
Julien PhalipandAlex Pláte c75e6756c0 Add some tests for the getcmdtype() function 2024-11-22 16:49:04 +02:00
Julien Phalipandlippfi 5db2984fdd Add ability to set the highlightedyank foreground color 2024-11-22 15:48:22 +02:00
Alex Plate ed2fe3dcf0 Fix(VIM-3696): Get the state of the selection in read action 2024-11-15 20:34:41 +02:00