Commit Graph

1252 Commits

Author SHA1 Message Date
Jason Fields
adb380dc96 Merge <BS> into DocumentContentChangeAction
This means fixing a typo no longer means the insertion will take several times as long to repeat. Rejoice!
Refs #4809
2021-07-22 17:57:43 -04:00
Jason Fields
03dd5bf435 Repeating an insertion which included arrow keys should always start from cursor position
This is the case regardless of how the original insertion started (`A`, `gi`, etc.).
There are still several problems (which I made note of), but this is a step in the right direction.
2021-07-22 14:09:06 -04:00
Jason Fields
e458b1f533 Run prettier 2021-07-21 14:21:54 -04:00
Jason Fields
c7f0220e2d Fix a few StatusBar messages; add test coverage of StatusBar messages
There's definitely more we could do with this, but it's a good start.
Fixes #5863
2021-07-21 13:33:15 -04:00
Jason Fields
83ddf644a1 Adopt new createStatusBarItem API with id and name
Fixes #6741
2021-07-20 20:27:21 -04:00
Jason Fields
c9ea28de86 Use statusBarItem.errorForeground and statusBarItem.errorBackground ThemeColors
Fixes #6100
2021-07-20 20:08:21 -04:00
Erik Demaine
10111ef6cd
Fix escaping in :s substitutions (#6891)
* `parsePattern` generally leaves backslashes alone, passing them on
  to the regular expression parser.
* New `parseReplace` interprets backslashes.  New definitions for `\b`
  (backspace), `\&` (same as `$&`), and `\0` through `\9` (same as
  `$1` through `$9`).
* Rewrite these parsers in imperative style to avoid any stack overflow.

Fixes #6890
2021-07-20 19:40:26 -04:00
Jason Fields
884dc480c2 Use 'deleteLeft' command for <BS> and 'deleteRight' command for <Del>
This makes VSCode handle it for us (as if we weren't capturing these keypresses at all). The most noticeable effect is that <BS> no longer closes the autocomplete popup.
Fixes #3613
2021-07-11 17:38:15 -04:00
Jason Fields
49b8e1386b 2i" should act like a", but exclude leading/trailing whitespace
Fixes #6806
2021-06-28 23:08:02 -04:00
Jason Fields
9c9a93cd08 Fix i" and a" when starting on a quote character
This should match quotes on the line to decide whether to go backward or forward.
Fixes #6761
2021-06-17 20:17:37 -04:00
Jason Fields
64ede25e4b a" includes trailing whitespace (or leading whitespace if none exists)
Fixes #6747
2021-06-16 00:54:52 -04:00
Jason Fields
fae36af866 Correct cursor position after actions like vi"c when cursor starts on "
Fixes #6740
2021-06-15 16:07:12 -04:00
Jason Fields
b92f488817 Fix corner case in HistoryTracker content merging
Fixes #6645
2021-06-11 17:37:16 -04:00
Jason Fields
cb61f9f77d <BS> deletes a soft tabstop in the leading whitespace of a non-empty line
Fixes #1691
2021-06-11 15:21:42 -04:00
Jason Fields
e199ffd931 Fix repeating insertions that contain auto-matched brackets
Fixes #6692
2021-06-09 18:34:17 -04:00
Jason Fields
b2c6102b3b Enable noImplicitOverride
Fixes #6670
2021-06-05 13:57:51 -04:00
Jason Fields
9d7377859c Fix cursor position after undoing/redoing certain actions
In particular, undoing a Visual/VisualBlock operator should now put the cursor in the right place.
Refs #6681
2021-06-02 16:58:50 -04:00
Abid H. Mujtaba
91b58999e9
Add Python-specific motions (#6393)
- Map ([|])(m|M) to motions to the prev|next start|end of Python functions
- Map ([|])([|]) to motions to the prev|next end|start of Python classes

Fixes #6213
2021-06-01 21:32:00 -04:00
Jason Fields
f0282c0c86 Slight change to HistoryTracker interface
At least currently, we only store a single cursor position per HistoryStep to restore on undo/redo. Let's be honest about that fact.
2021-06-01 00:13:30 -04:00
Jason Fields
4ba5da3740 Ex commands like :s should create undo points
See #5058 for some background on this issue, which really needs rationalization.
2021-05-30 22:13:47 -04:00
Jason Fields
338c202c5a Use transformation for increment/decrement 2021-05-30 16:44:23 -04:00
Jason Fields
3fd358d7ad Fix :sort with both (i)gnorecase and (u)nique flags set 2021-05-30 16:00:15 -04:00
Jason Fields
d25f6676ad Use transformation for :sort and fix cursor position 2021-05-30 15:36:06 -04:00
Jason Fields
6b03413559 Run prettier 2021-05-29 22:52:13 -04:00
Jason Fields
fe6a154f78 Rename custom Range class to Cursor
Refs #4585
2021-05-29 21:15:20 -04:00
sql-koala
be2a52af5e
Surround Rewrite (#6452)
This reduces the jank of the surround plugin substantially, fixes a number of bugs, and uses an InputBox for specifying tags.
Fixes #1818, fixes #5211, fixes #2893, fixes #6564, fixes #3386
2021-05-29 15:17:33 -04:00
Jason Fields
7103285539 Enable strictPropertyInitialization
Fixes #5847
2021-05-28 21:34:16 -04:00
Jason Fields
f22fbed657 Merge <C-y> and <C-e> in Insert mode with DocumentContentChangeAction
Repeating these should do the same insertion, regardless of what's below/above the cursor.
2021-05-28 17:19:23 -04:00
Jason Fields
5e2b9ce25e Expand and organize test suite a bit
- `I`, `gI`, `gi`
- `w` and `go` motions
- `<C-a>` in Insert mode
- `<C-y>` and `<C-e>` in Insert mode
- `.` after content change with `<BS>`, `<Del>`, and `<CR>`

Refs #5033
2021-05-28 16:23:03 -04:00
Jason Fields
518d3d5923 Clean up :substitute test suite 2021-05-28 15:28:49 -04:00
sekai013
f4a46889cc
Fix substitute with backslash (#6409)
Fixes #2710
2021-05-28 14:07:41 -04:00
Jason Fields
a111baa3ff Make n and N act as failed motions at end/start of document with nowrapscan
Refs #4908
2021-05-10 22:48:12 -04:00
renovate[bot]
3f6ba73944
Update dependency prettier to v2.3.0 (#6604)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-10 01:29:40 -04:00
Jason Fields
95cc88b1d5 Make gn act as failed movement if there are no more instances of the search term
Fixes #5194
2021-04-29 21:55:39 -04:00
Erik Demaine
ddf93f6a93
gq preserves whitespace between line breaks (#6571)
Rewrite `gq` reflow to apply manual spacing (including `joinspaces`
option) just when creating whitespace from what were linebreaks.
Fixes #6569

Fix precision around `textwidth`
Fixes #3509
2021-04-29 21:24:32 -04:00
Jason Fields
82ff74abcc Fix <C-w> in Insert mode at start of document
Fixes #6529
2021-04-22 11:59:37 -04:00
Jason Fields
d055eda3a3 Get rid of deprecated insertAt 2021-04-22 00:22:14 -04:00
Jason Fields
80dae08a5f Fix cursor position after <C-d> and <C-t> in Insert mode 2021-04-22 00:13:02 -04:00
Erik Demaine
2d8ce4304a
Support joinspaces in join and reformat paragraph (#5895)
Fixes #2505
2021-04-19 21:43:34 -04:00
Jason Fields
9fb7cb4d2f Collapse all cursors in Normal mode, not just the first
This could cause cursors to get mixed up, leading to weird multicursor bugs
2021-04-14 00:44:39 -04:00
Jason Fields
8df8ab9ad7 Re-write put from scratch
I finally bit the bullet, deleted all of our put logic, and re-implemented it from scratch.
This includes `p`, `P`, `gp`, `gP`, `]p`, `[`, and `:put`.

In addition to cleaner, more maintainable code, this resulted in:
  - Using replace transformations, which means better performance
  - Fixing VisualBlock put and block-wise put (fixes #1796)
  - Fixing put when the register contains a macro (fixes #3714)
  - Fixing various other corner cases, particularly with regards to cursor placement
  - Beefing up our test suite

I'm sure there are still obscure corner cases that we handle wrong, but it'll be easier going forward to fix them.
2021-04-13 20:19:32 -04:00
Jason Fields
045cabeef5 Big fat refactor of registers
- Each register now points to an array - the i'th slot contains the content for the i'th cursor
- If there are more cursors than slots, the first slot is used as a backup
- Each slot contains either a RecordedState (in the case of a macro) or a string
- Newlines in those strings should be interpreted in the context of the associated RegisterMode
- The interface was changed somewhat to be safer and more consistent

I probably broke *something*, but the tests pass and this refactor enables further improvement of the terrible put logic, so I'll fix things as they come up.
2021-04-09 23:17:59 -04:00
Jason Fields
f4a2b61ce4 Fix cursor position after yanking multiple lines and [count]p
This is all so janky...
2021-04-09 14:40:29 -04:00
Jason Fields
9e83bfaed7 Test cases for character-wise put commands with count in normal mode
Several of these result in incorrect cursor positions - this has been noted with comments
2021-04-09 12:22:51 -04:00
Jason Fields
1873effd4c Make gP and ]P respond to [count] and dot
Fixes #6416, Fixes #6444
2021-04-09 00:52:53 -04:00
Jason Fields
f5c3cdd841 Remove a few stupid, hardly used methods from Position 2021-04-08 18:46:10 -04:00
Jason Fields
9e50e0dc52 Refactor interface of Position's "word" methods
- Rename word methods to be more intuitive
- Use Position methods instead of standalone functions
- Use an object for pseudo-kwargs
- Pass WordType instead of having separate methods for "big" words
- Take `TextDocument` as a parameter

The result is a bit verbose (a more fundamental refactor might be needed
at a later date), but it's consistent, safe, and extensible.
This prepares for some changes to fix corner cases in our word handling.

Refs #5663
2021-04-08 18:12:26 -04:00
Jason Fields
057cfc58ed <C-u> in insert mode deletes line break when used at start of line
Fixes #6429
2021-04-06 23:21:43 -04:00
sql-koala
594b308597
Use transformations for :s (#6402)
This fixes some edge cases as well as doing the edits in parallel
Fixes #4915, Refs #5663
Known issue: interactive `:s` does not update the document until the last replace is confirmed
2021-04-05 20:53:25 -04:00
Jason Fields
f86273d252 Small refactor of Jumps 2021-04-04 22:17:49 -04:00
Jason Fields
009b5d52ad Yank should move cursor to start of range (or, if linewise, to first line of range)
Fixes #4871
2021-04-04 21:22:15 -04:00
Jason Fields
f2df5e45aa Fix X in Visual and VisualLine modes
This should delete entire selection linewise.
Fixes #6408
2021-04-04 18:35:25 -04:00
Jason Fields
86a4ed05a7 Remove last instance of TextEditor.delete 2021-04-02 00:41:15 -04:00
Jason Fields
63f4160107 Overhaul HistoryTracker
- Much better edit merging, so undoing/redoing should generally only take one replace
- Correct changelist edge cases
- Improve and organize related tests

Known issue: `U` after `O` is broken, but that's a small corner case and `U` is generally much better behaved now.
2021-03-31 22:14:07 -04:00
Jason Fields
1c2cdc26be Remove Globals.mockModeHandler, which is no longer necessary 2021-03-31 18:40:24 -04:00
Jason Fields
a6c65cf50a Organize and flesh-out tests for gg and G
Refs #5033
2021-03-29 20:03:50 -04:00
Jason Fields
11a4a87032 Slight refactor of test harness
This simplifies things, reduces jank, and makes test setup a little bit faster. A lot more refactoring could be done, but this is a good start.
2021-03-29 20:01:43 -04:00
Jason Fields
e606f5599d <BS> in replace mode goes over EOL
Fixes #6371
2021-03-29 11:03:54 -04:00
Jason Fields
a578a0b8d8 Fix [count]R
It was inserting the newly-entered characters again, rather than repeating the replace.
Fixes #6370
2021-03-28 21:43:09 -04:00
Jason Fields
a0f37f6eb7 Fix <BS> in replace mode when cursor is already before where it started
Fixes #6369
2021-03-28 21:16:50 -04:00
Jason Fields
d96ebf0c9b Remove a few instances of any
We love type safety, don't we folks?
2021-03-28 20:14:10 -04:00
Jason Fields
c45a73b2cd [count]<C-v> selects <count> characters 2021-03-28 19:17:13 -04:00
Jason Fields
79a570c0c3 Fix [count]gp in visual mode 2021-03-28 15:58:24 -04:00
Jason Fields
04068bf842 [count]v in normal mode selects <count> characters 2021-03-28 15:28:08 -04:00
Jason Fields
f19ccecec2 Fix [count]p in visual mode
Fixes #6357
2021-03-26 23:03:45 -04:00
Jason Fields
18327e0ff0 Improve startup performance by calling getCommands only once 2021-03-26 14:27:05 -04:00
Jason Fields
4043c978bd Remove leading underscores from private members
(Except when they're necessary because of getters/setters)
2021-03-22 00:06:36 -04:00
Jason Fields
6a6afd8bef Fix build 2021-03-21 23:36:09 -04:00
Jason Fields
daee0c0226 Remove some unused variables 2021-03-21 22:56:20 -04:00
sql-koala
b557d4da41
Support visual mark movements ('<, '>, <, >) (#5056)
Fixes #2690
2021-03-16 18:51:07 -04:00
Thad Sauter
d280a0ee6c
Support bd[!] [N] to close buffers (#4478)
Fixes #3638
2021-03-16 14:54:02 -04:00
Ignacio Alvarez
ebf9fe74bc
Support for delm[arks]! (#4748)
Fixes #4682
2021-03-15 22:56:50 -04:00
Jason Fields
e35a29a56b Use notStrictEqual instead of the deprecated notEqual 2021-03-11 11:09:27 -05:00
Evgeny Gryaznov
32d5b92f5c
Fix even more dependency cycles (#6243)
Refs #6177
2021-03-10 22:39:25 -05:00
Jason Fields
cfb966a39a Log error when module fails to resolve in tests
Fixes #6244
2021-03-08 12:53:05 -05:00
Jason Fields
5a2dc0210d Simplify tslint.json by extending tslint:recommended
As a side-effect, our linting just got substantially stricter, and this had to be a pretty wide-reaching change to comply. Sorry if this complicates any merges!
2021-03-05 20:20:44 -05:00
Jason Fields
63efa33f21 Proper implementation of whichwrap
Implement missing values, set default to 'b,s', and add some test cases
2021-03-04 22:39:14 -05:00
Jason Fields
fe44b204a9 Handle <S-BS> correctly on command line 2021-03-04 18:43:52 -05:00
Jason Fields
23fdc704b0 Fix a few small bugs with <BS> in normal/visual modes
- In normal mode, wrap only if 'b' is in `whichwrap`
- Move back a character in visual line mode
- In all modes, treat <C-BS> and <S-BS> as <BS>
2021-03-04 14:57:47 -05:00
Jose Alvarez
7f1972dd89
Implement previous context marks (#6174)
Implements previous context marks as described in Vim's help m' / help m`.
Fixes #4873
2021-03-01 15:17:29 -05:00
Jason Fields
00872cbb0a gi should put cursor at start of document in insert mode if there's no prior insertion
Fixes #6189
2021-02-23 12:17:43 -05:00
Jason Fields
f211022f5e Pass TextDocument to TextEditor.getFirstNonWhitespaceCharOnLine()
Refs #5663
2021-02-22 23:45:13 -05:00
Jason Fields
eab7f0b48e Pass document explicitly to a few more TextEditor functions
Refs #5663
2021-02-22 21:37:23 -05:00
Jason Fields
5be9ef9905 Remove some deprecated TextEditor functions
Refs #5663
2021-02-22 21:12:30 -05:00
Jason Fields
a6c0fce4ae assert.deepEqual -> assert.deepStrictEqual
The former is deprecated
2021-02-22 20:16:16 -05:00
Austin Clements
c2e0e1278d
Neovim config support (#5071)
Set `vim.neovimUseConfigFile` to true to use this feature
`vim.neovimConfigFile` points to the vimrc path; will use default path on system if left blank
Fixes #5045
2021-02-18 21:26:08 -05:00
renovate[bot]
a12d19a46c
Update dependency @types/node to v12.20.1 (#6133)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-16 18:41:42 +00:00
Jason Fields
ae21e51b40 Normalize <S-x> to X
Fixes #6110
2021-02-08 13:31:14 -05:00
sql-koala
802225aa47
Fix put with <C-r> in multi-cursor insert mode (#6065)
When there are the same number of yanked values as there are cursors, we should not combine the values, but "spread" them across the cursors.
2021-02-01 12:59:33 -05:00
Jason Fields
c36b5b490c Enable noImplicitAny in tsconfig
Still need to disable `suppressImplicitAnyIndexErrors`, but that's better done in a separate commit, I think.
Refs #6034
2021-01-25 13:07:59 -05:00
Erik Demaine
3bc767c47e
Fix 'cw' behavior on whitespace (#6033)
When `changeWordIncludesWhitespace` is `false`, 'cw' is supposed to act
like 'ce' when the current character is a non-blank.  However, it is
supposed to act like a regular 'w' motion when activated on a blank
character.  This fixes a small typo for correctly detecting this case.
2021-01-25 12:50:32 -05:00
Erik Demaine
611734eba8
Make gq preserve blank lines (#5892)
Fixes #2393
2021-01-24 15:33:52 -05:00
Zack Stickles
8a9f47d2be
Add setting to show marks in gutter (#5924)
Enable `vim.showMarksInGutter` to enable this feature.
Fixes #5119
2020-12-28 14:57:34 -05:00
Jason Fields
bf247f8d77 Fix tests 2020-12-10 15:05:41 -05:00
Jason Fields
3c59a4e6f4 Move put tests in modeNormal.test.ts to put.test.ts
Tiny step toward #5033
2020-12-10 14:52:39 -05:00
Jason Fields
185af2babb :s[ubstitute] with tab character (\t)
Fixes #2501
2020-12-08 14:20:27 -05:00
Jason Fields
8631f9982c Move remapping-related state from VimState to new RemapState
The motivation behind this is mostly to reduce the surface area Actions can interact with.
Remappings should not be visible to them (this is fundamentally logic internal to ModeHandler/Remapper).
2020-12-07 20:57:37 -05:00
Jason Fields
d81819a2b0 Small refactor: remove vimState parameter from IRemapper.sendKey
This is always the same as `modeHandler.vimState`; let's make that clear.
2020-12-07 20:42:00 -05:00
berknam
f183f51b2b
Fix CommandSearch throwing error in multicursor (#5845)
- Searching with `/` or  `?` no longer throws "Maximum call stack size exceeded"
- Add tests for searching with '/' and '?' with multicursors
Fixes #5844
2020-12-07 13:07:52 -05:00
Jason Fields
1c0072af63 Remove more instances of activeTextEditor
Refs #5663
2020-12-06 14:41:56 -05:00
Jason Fields
a58861df9a Get rid of Position.getUpWithDesiredColumn and Position.getDownWithDesiredColumn
IMO, these were more confusing than they were worth.
2020-11-24 19:24:52 -05:00
renovate[bot]
bb9a78979d
Update dependency typescript to v4.1.2 (#5703) 2020-11-20 13:53:31 -05:00
Jason Fields
3e56996a75 Simplify testItWithRemaps slightly
The use of nested Promises here hurt my head when trying to accommodate a breaking change in typescript 4.1, so I'm just sorting this out for myself before doing the typescript upgrade.
2020-11-20 13:41:53 -05:00
Jason Fields
6c93c819df Reduce usage of unnecessary TextEditor methods
These are thin wrappers around `activeTextEditor`, which I'm trying to get away from using, because it creates race conditions.
Refs #5663
2020-11-18 13:15:52 -05:00
sql-koala
2b7a32172d
Fix n with matches at EOL (#5678)
This improves handling special cases where a search match is at EOL when jumping to next match using "n".
Fixes #5591
2020-11-18 01:38:08 -05:00
Jason Fields
260f081b6b <C-l> in search mode
This "extends" the search term to include the next character of the first match.
Fixes #5675
2020-11-17 17:39:29 -05:00
berknam
bbf88e4ea6
Implement normalization for 'Shift+Tab' key combo (#5587)
<Shift+Tab> key was being captured but had no normalization implemented, so only '<shift+tab>' would work.
This commit makes '<S-tab>' work as well.
Fixes #4719
2020-11-17 13:46:11 -05:00
Jason Fields
c6b4cec68d Add vimState.document getter
Just removing a bit of boilerplate which will make ripping out unnecessary TextEditor methods slightly less painful.
Refs #5663
2020-11-16 16:04:45 -05:00
Jason Fields
e191e13d5f Reduce use of activeTextEditor in favor of vimState.editor
Refs #5663
2020-11-16 15:43:41 -05:00
Jason Fields
8a15cdb842 Make getAndUpdateModeHandler return undefined when there is no active editor
This means `vimState.editor` should never be undefined - now we should start using that instead of `vscode.window.activeTextEditor` to avoid a whole bunch of pesky race conditions.
Refs #5663
2020-11-16 14:58:05 -05:00
Jason Fields
1564e647dc Replace getTestingFunctions with plain old exports/imports
Not sure why it was ever done this way
2020-11-16 13:42:09 -05:00
rickythefox
de2cc63390
Fix [count]p in visual line mode (#5504)
[X]p did not work in visual line mode. I've split PutCommandVisual and created a separate command for putting in visual line mode. This works by using the move count to temporarily replace the register content with a repeated version of itself. This is then used in the regular PutCommandVisual and the register is restored.
Fixes #5442
2020-11-14 17:23:29 -05:00
Jason Fields
ba244bb4ce Stop using custom Position class in favor of augmenting vscode.Position
This means no more need to convert back and forth between the two.
Closes #4820
2020-11-13 21:48:12 -05:00
Jason Fields
477e4c2ca8 Move paragraph logic from position.ts to textobject/paragraph.ts
Refs #4820 again, of course
2020-11-13 20:46:10 -05:00
Yizhi Xu
f0e84a4bbd
Fix i{ when inner content is already selected or when a count > 1 is given (#5093)
Fixes #4275
2020-11-13 13:39:42 -05:00
berknam
31d4dd9db6
Fix multicursor selections visual mode (#5250)
Currently when you have selections with multicursors if you move in a way that those cursors would combine would then result in a situation where our 'updateView' function would think that there was a different selection even when there wasn't, because it was still thinking it should have 2 selections.

This would result in our selections to be ignored count increasing and there would never be a selection change to clear that count, so any future selection changes would be ignored until the document was closed and reopened or vscode window was reloaded or restarted.

This seems to happen a lot of times when using snippets, because now when inserting a snippet it turns the selections to visual mode multicursor and sometimes if the user moves up/down without noticing that it is in visual mode (since previously it would still be in insert mode, but this is a different issue that I'm currently working on trying to make snippets not go into visual mode) then in those case it can create the situation I mentioned above. And the user will probably not even notice it until they click somewhere and try to move.

Fixes #5212, fixes #5248, fixes #5221, fixes #5268 fixes #5380
2020-11-01 16:12:26 -05:00
berknam
119cf137d6
Fix bug with remap in insert mode (#5280)
- Potential remapped keys in insert mode followed by another key that is
itself an insert mode remap would not insert the first potential key
- This was due to a old piece of code that allowed for remaps in
insert mode to have other keys preceding them. So if you had 'jk' mapped
to 'Esc' and had 'ctrl+e' mapped to something else, if you pressed 'j'
and then 'ctrl+e' it wouldn't insert 'j' because it was allowing
'j<C-e>' to be considered a valid remap
2020-10-31 20:23:23 -04:00
berknam
c671b3b88d
Stop user forced stop remap from throwing error (#5425)
- When the user force stops a recursive remapping it shouldn't throw an
error, it should just set the 'vimState.forceStopRecursiveRemapping'
which will then make all the remaining keys be ignored until the
recursive remap finishes.
- Add test for forced stop remaps on non infinite recursive remaps.

Fixes #5419
2020-10-15 13:39:21 -04:00
berknam
063aee4993
Fix remap bug with '<' and special keys remaps (#5287)
- Fix remaps confusing '<' as potential remap to special keys like '<C-x>'
- Add test for this situation
- Prevent showing special keys like '<C-x>' with virtual key decoration

Fixes #5188
2020-09-29 00:11:44 -04:00
Peng Lyu
c900a7eaa8
Nodeless entry for Vim extension (#5130)
Add a new entry for running Vim in nodeless environment and load platform-specific modules based on the target.

This PR includes changes to:
- fs. In node, it's node's native fs; in nodeless, it uses vscode.workspace.fs.
- historyFile. In node, it stores the history in file system; in nodeless, it stores in memory.
- logger. In node, it uses winson; in nodeless, it uses browser console.
- lastly, it relies on Webpack to tree shake unwanted code paths (for example, remove nvim related code paths from the bundle in nodeless environment).
2020-09-20 13:57:38 -04:00
Ayman Bagabas
b348e08bb7
Add support for smartRelativeLine (#5010)
Adds support for smartRelativeLine, which toggles VSCode's line numbers between absolute and relative depending on the current mode.
Fixes #3020
2020-09-15 12:19:56 -04:00
Jason Fields
dfe5e3966c Remove VimState.registerName
This isn't used anywhere; the "active" register is held on RecordedState.
2020-08-28 00:25:41 -04:00
Jason
84e3e722b3 Better error handling when a register has no value
Register.get() will now return undefined when the given register has no value, which lets us throw E353, etc.
2020-08-16 18:46:44 -04:00
berknam
91ca71f860
Overhaul remapping logic (#4735)
This is a pretty massive change; see pull request #4735 for full details

Most notably:
- Support for operator-pending mode, including remaps and a half-cursor decoration
- Correct handling of ambiguous remaps with timeout
- Correct handling of recursive special case when the RHS starts with the LHS
- Correct handling of multi-key remaps in insert mode
- Failed movements that occur partway through a remap stop & discard the rest of the remap
- Implement `unmap` and `mapclear` in .vimrc

Refs #463, refs #4908
Fixes #1261, fixes #1398, fixes #1579, fixes #1821, fixes #1835
Fixes #1870, fixes #1883, fixes #2041, fixes #2234, fixes #2466
Fixes #2897, fixes #2955, fixes #2975, fixes #3082, fixes #3086
Fixes #3171, fixes #3373, fixes #3413, fixes #3742, fixes #3768
Fixes #3988, fixes #4057, fixes #4118, fixes #4236, fixes #4353
Fixes #4464, fixes #4530, fixes #4532, fixes #4563, fixes #4674
Fixes #4756, fixes #4883, fixes #4928, fixes #4991, fixes #5016
Fixes #5057, fixes #5067, fixes #5084, fixes #5125
2020-08-16 14:22:51 -04:00
Jason
2254e8e9f6 Merge Register.get() and Register.getByKey()
Just a small refactor to simplify the register API slightly
2020-08-16 13:44:41 -04:00
J.R. Maingat
e0da682ac0
Fix :p[ut] command neovim capability and subparser (#5063)
Enables neovim capability and fixes arg parsing for the `:p[ut]` command. Apparently the put command allows no whitespace between the command name and the register name, so commands like `:put"` are perfectly valid. I've added some subparser tests to document this.

Fixes #5052
Fixes #5090
2020-08-14 23:36:48 -04:00
Jason Fields
ac9c405901 Remove a bunch of type assertions, enable tslint rule disallowing unnecessary type assertions 2020-08-13 19:58:05 -04:00
berknam
3879f4374b
Change easymotion default decorations (#5108)
- Make easymotion default decorations have the same defaults as the Vim
plugin.
- Deprecate no longer needed configurations like
'easymotionMarkerMargin' and 'easymotionMarkerWidthPerChar'.
- Change 'easymotionMarkerFontWeight' default to 'bold'
- Add seperate color for each character of two-character markers,
default values are the same as the Vim plugin. (two different yellows)
- Add color for dimmed characters, default value is the same as the Vim
plugin. (grey)
- Add color for higlighting characters searched with search n-characters
command, default value is the same as the Vim
plugin. (green)
- Add changes to README file and update the default values.
- Change easymotion TextEditorDecorations to make them simpler to use
and understand. Remove all unnecessary parts.
- Fix the dimming zones that were including the markers as well.
- Fix the hack for two consecutive markers that wasn't checking if those
markers were on the same line.

Fixes #5092
Fixes #5022
Fixes #4252
Fixes #1746
2020-08-11 23:36:04 -04:00
Jason Fields
59b8d3115c Enable --resolveJsonModule to get type safety on package.json import 2020-08-07 21:39:26 -04:00
Kevin
b68124b6b7
Fix cursor position after surround in Visual mode (#5076)
Fixes #4869
2020-07-26 15:33:14 -04:00
berknam
35d06e6780
Implement better synchronization of selections (#5015)
- Store our selections when calling 'updateView' to be later ignored.
- Create a 'ignoreIntermediateSelections' flag that is set when running
an action to ignore any selection changes triggered by any step of that
action.
- When getting a selection change event we first check if it is one of
our selections. If it is we ignore it, if it is not we still ignore it
if the 'ignoreIntermediateSelections' flag is set or if we have other
selections to ignore, because that means this selection slipped in after
the end of the action. Otherwise we handle it.
- Create new handle for selection changes with kind 'Command'. (this is
triggered by editor commands like 'smartSelect.grow' but is also
triggered when we set the 'editor.selections' on 'updateView', except
this last one will now be ignored)

Fixes #1806
2020-07-25 14:45:52 -04:00
berknam
0a5093f4b1
Fix visual mode not preserving desiredColumn (#5049)
When moving horizontally on visual mode the desiredColumn wasn't being kept correctly, because we were updating the desiredColumn after correcting our cursors by shifting the stop to the right so that vscode included our stop on its selection.

Fixes #5048
2020-07-23 00:37:21 -04:00
Jason Fields
4dcfdbd2c9 Better handling of whitespace on command line
- Don't trim() the command before parsing & executing it
- Ignore whitespace while lexing LineRange

Fixes #5039
2020-07-21 20:17:22 -04:00
sql-koala
62867b258c
Make gg a linewise motion (#5046)
Fixes #4806
2020-07-20 11:39:53 -04:00
J.R. Maingat
bca06cd994
Implement filter commands (#5042)
This PR implements filter commands, which allows filtering lines in the buffer with an external command.
The following operators are implemented here:

- !{motion}{filter}
- !!{filter}
- {Visual/Visual block/Visual line}!{filter}

Fixes #4166
Fixes #4857
2020-07-18 01:47:44 -04:00
sql-koala
67c53226f0
Bugfix: search backwards with operator (#5041)
This PR removes an unnecessary restriction that prevents search backwards ("?") with an operator.

Fixes #4506
Fixes #4647
2020-07-17 15:53:12 -04:00
zimio
95371fbb9f
Add :sh[ell] command (#5040)
This opens up VS Code's built-in terminal
2020-07-17 13:08:24 -04:00
sql-koala
bc29cd5746
Support undo count (#5038)
This PR adds support for a count to undo ("u").
Fixes #4963
2020-07-17 11:33:42 -04:00
fujimoto kyosuke
2b47110930
Support gJ in visual modes (#5037)
Fixes #5027
2020-07-17 00:09:16 -04:00
zimio
3d1aca2e6f
Implement :ju[mps] and :cle[arjumps] commands (#5021)
Fixes #4872
2020-07-16 14:21:05 -04:00
fujimoto kyosuke
a1fecb8b80
Fix [count]gJ (#5014)
Fixes #2207
2020-07-16 11:12:29 -04:00
Jason Fields
34125c37d1 Implement progressive increment/decrement (g<C-a> and g<C-x>)
Fixes #3226
2020-07-15 15:47:31 -04:00
Jason Fields
7a1778093e Implement increment/decrement in visual modes
Fixes #4112
2020-07-15 15:33:55 -04:00
sql-koala
c9eb9d30e9
Implement count for CommandDot (#5025)
Fixes #2192
2020-07-15 13:19:37 -04:00
sql-koala
ec6d834ee8
Fix textobject: a paragraph ending position (when paragraph is single line) (#5023)
This PR fixes a small bug, also described in the linked issue.
Right now, when you operate on "ap" (cap, dap, vap, ...) and the paragraph is a single line, vscodevim will operate till EOF.

Fixes #5012
2020-07-15 12:06:12 -04:00
Merikan
fc50007327
Textobject argument improvements (#5004)
This PR improves the argument movement, by handling some more edge-cases and being less aggressive on the existing whitespaces in the argument (i.e. preserving indentation-level) when doing the inner argument movement.

One of the edge-cases was not checking that the cursor is actually inside the delimiters, i.e. that we actually are inside an argument list. This caused the movement to span to the neighboring separators (,) across the buffer. This PR adds a check to fail the movement right at the beginning.
Unfortunately this requires 2 scans for delimiters/separators on successful movements. I think this is okay for the current scope of argument lists, since the search range is quite limited on the second scan. In a future update one could rework the logic, so that the find-functions actually keep track of all the visited separators on the first scan.

On another note: This early failure could be relaxed in a further update, so that comma-separated lists when they are on a single line are a valid movement (there may be several cases, where this feature could be useful, e.g. from x import a, b, c in python).

This is a direct successor to #4653
2020-07-13 12:01:26 -04:00
Jason Fields
478401d760 Improve behavior of [g]* and [g]#
- Skip over word separators (as defined by `iskeyword`)
- Do not go over line breaks (throw E348)
- Escape characters in word so you can search for characters like `{`

Fixes #4808
2020-07-09 00:27:14 -04:00
lmNt
908133bb2b Improve select around to include leading whitespace in second argument when on first argument 2020-07-06 18:27:18 +02:00
lmNt
83e2d32d83 Introduce configuration for argument text object 2020-07-06 18:27:18 +02:00
lmNt
aa04da582a Remove test case for mismatched delimiters for SelectArgument textobject
Instead annotate in a comment, that this edge-case will not be handled for now,
because I can not think of any case, where this would cause undesired behaviour
2020-07-06 18:25:22 +02:00
lmNt
0948989b63 Test that nested parentheses in current argument are properly handled
fixes #2338
2020-07-06 18:25:22 +02:00
lmNt
b39c5075aa Add more test cases and fix the bugs alongside
fixes #2338
2020-07-06 18:25:22 +02:00
lmNt
8cbb30beeb Implement textobject movement for inner and around argument
fixes #2338

This commit implements SelectInnerArgument and SelectAroundArgument
based on a common base class and adds a first bunch of tests.
NOTE: Not all of them pass yet.
2020-07-06 18:25:22 +02:00
J.R. Maingat
e7c5c70f9f
Implement ":!" bang command (#4989)
This PR ports the :!{cmd} bang command from Vim, allowing external shell commands to be run directly from Vim's command mode.

Key features:
- :!{cmd} executes the shell command
- :{range}!{cmd} executes the shell command, pipes the line range to stdin, and replaces the line range with the output from stdout and stderr
- Embedded bangs are replaced with the previous bang command (e.g. :!dir => :!echo ! will execute echo dir)
- Cross-platform, supports Unix and Windows shells

Fixes #3154, fixes #3136, fixes #3069, fixes #4920
2020-07-06 11:31:48 -04:00
Jason Fields
d178158d46 [g]* and [g]# should ignore smartcase
Fixes #1800
2020-07-05 22:12:27 -04:00
Jason Fields
147ac8c757 Add config option to newTest, which will override specific settings for the duration of that test
This makes testing different setting combinations MUCH easier.
Settings coverage is very much lacking in our test suite, which we should definitely make an effort to improve. More sane test organization and automated code coverage detection would make our gaps more obvious.
2020-07-05 22:00:46 -04:00
Peng Lyu
5c7443c344
Preparation for running extension in nodeless environment (#4981)
VS Code is adding support for running extensions in a nodeless environment. This PR tries to refactor the code a bit to allow later on replacing node APIs (fs, child_process) with shims.

This PR should not change any functionality for running Vim in desktop.

Once we can run Vim in a web worker, we can also think about running Vim in its own worker, which at the end will help with the performance issue: https://github.com/microsoft/vscode/issues/65876
2020-06-30 15:58:03 -04:00
berknam
6c98ba3b27
Fix surround alias using wrong shortcut version (#4985)
- Shortcut aliases were using the version with space but they are supposed
to use the version without space
- Add 'a' shortcut alias to '>'
- Add tests for alias
- Add some tests for visual and visual line mode (they are not extensive
but should be enough for now)
Fixes #4965
2020-06-30 14:12:03 -04:00
Jason Fields
d662a5025f Fix tests by enabling surround only for surround tests 2020-06-30 12:12:35 -04:00
Adam Hawley
c77c466628
Add :u[ndo] ex command (#4980)
Fixes #3197
2020-06-28 17:48:14 -04:00
berknam
0c89ce06b7
Fix macros not handling registers correctly (#4975)
- Recording a macro with an uppercase letter whose register doesn't
exist yet, now creates that corresponding register
- After finishing recording a macro by pressing 'q' no longer throws an
error with 'concat'
- Calling a macro that doesn't exist no longer throws error. It just
returns the same vimState.
- Add tests for these cases

Fixes #4948
2020-06-28 16:38:58 -04:00
Ahmed Tarek
b95d038fe1
new dimming logic, updated docs (#4635)
The current easymotion decorations are kinda wonky, they are misaligned and little bit intrusive, also it deviates from the official easymotion. With this pr it behaves more like the official

Fixes #4610
Fixes #4524
Fixes #3899
Fixes #2938
2020-06-22 10:53:10 -04:00
berknam
80deadf056
Change count handling on remapping, vscode commands and operators (#4866)
- The count value is already stored on RecordedState so we only need to
send the remap keys and the corresponding actions will act accordingly
- The commands weren't respecting the count, if we mapped '<' in visual
mode to the command 'editor.action.outdentLines' we couldn't use it with
count, now we can.

Fixes #2244
Fixes #4903
2020-06-17 12:55:08 -04:00
J.R. Maingat
25b9380aef
Implement put ex command (#4832)
This PR ports the :put and :put! ex commands from Vim, as described by the official documentation. The command is just a way to put text on the line above or under the cursor (always linewise).

Key things this PR adds/modifies:
- Refactors PutCommand to take in an object of boolean flags, instead of a bunch of boolean parameters
- Adds two new PutCommand flags to force linewise put and force cursor to move to the last line of pasted text
- Creates a new ex command PutExCommand with full testing suite

Fixes #4741
2020-06-16 15:08:55 -04:00
Jason Fields
d43a6e1ef4 Fix various issues with C, R, and S in visual modes
Fixes #4812
2020-06-14 21:09:48 -04:00
Mike Chen
7080bca327
Fix path delimiter issue with neovim detection (#4907)
Mac/Linux uses `:` for the PATH delimiter. Using `path.delimiter` to be platform-agnostic.

Fixes #4902
2020-06-14 18:42:27 -04:00
berknam
83e135221c
Fix docker tests (#4935)
- Stop docker tests from sending the entire app as context to the daemon
when building the image
- Add '--rm' to the container run command to remove the container when
done with the tests
- Fix paths to extensionDevelopmentPath and testsRoot
2020-06-09 15:48:57 -04:00
Jason Fields
68f89cda4e Fix warning about Mocha's useColors being deprecated 2020-06-08 11:02:05 -04:00
Jason Fields
24d722eda9 Remove newTestOnly 2020-05-25 14:44:31 -04:00
Jason Fields
e34d4dae85 General cleanup 2020-05-21 23:43:40 -04:00
Jason Fields
9a72779ca8 x with count should not delete newline
Fixes #4887
2020-05-21 18:37:48 -04:00
Jason Fields
4e31f95879 Fix flaky test 2020-05-19 20:37:02 -04:00
Jason Fields
c7f0729c17 Migrate from vscode to @types/vscode and vscode-test
Fixes #4448
2020-05-18 13:32:29 -04:00
Donough Liu
dee1c22300
Refactor <C-a> and <C-x> logic (#4469)
This PR totally fixes #4308, fixes #4457 and more.
Please check newly-added tests to get part of what this PR achieves.
These tests all fails without this PR, all of them are the correct behavior of original vim.
2020-05-18 13:07:14 -04:00
Jason Fields
c204f51309 Make a few tests pass on windows, make test failure messages more helpful
Refs #4844
2020-05-16 22:05:28 -04:00
Jason Fields
1ea49a46ab Display visual selections correctly while using surround
The position your cursor goes to after using visual surround is still wrong, but that can be fixed later.
2020-05-16 19:42:20 -04:00
Jason Fields
0085a0d22b gulp forceprettier 2020-05-14 11:31:43 -04:00
Fata Nugraha
4ec5e10093
Reset vimState.actionsCount when <C-o> pressed in insert mode (#4849)
Fixes #4841

The existing implementation did not reset vimState.actionsCount when we perform action that put user in insert mode after pressing <C-o>
2020-05-14 11:30:21 -04:00
Fata Nugraha
f2f30e4649
Throw E29 on empty . register (#4851)
Fixes #4846
2020-05-14 11:22:13 -04:00
Jason Fields
c2490b824a Place cursor at first non-whitespace character on line when pasting over visual line selection
Fixes #4843
2020-05-13 12:06:29 -04:00
Gergely Tóth
ece3438b18
Tag motion now considers the tag starting on the cursor line (#4721)
When executing yat or dat on a line where a new tag is opened (and there are only whitespaces between the beginning of the line and the opening < of the tag and the cursor is either on one of these whitespaces or on the opening <), the current version of the extension copies or deletes the outer tag, whereas Vim operates on the inner. This PR corrects the extension's behaviour.

Fixes #4685
2020-05-12 21:04:29 -04:00
berknam
d45d5e0db3
Add test to macros to prevent issues like #4827 (#4836)
After the PR #4830 I found weird that none of the tests captured the issue #4827.

After looking up the tests I found that there were no macro tests that handled multiple lines on same macro (like what happens on that issue) so decided to create a new test to prevent future issues like that one.
2020-05-12 19:45:50 -04:00
berknam
67cde5765e
Fix bugs with a remapped <Esc> in insert mode (#4829)
- Fix DotCommand deleting extra character when used after a remapped <Esc> in insert mode
Fixes #4817
Fixes #4814

- Fix remapped <Esc> leaving trailing character when used with multiple cursors
Fixes #4811

Co-authored-by: Jason Fields <jasonfields4@gmail.com>
2020-05-12 19:30:00 -04:00
Jason Fields
f8d7296be2 Refactor DocumentContentChangeAction 2020-05-08 17:35:59 -04:00
Gergely Tóth
bb608fbf68
Fix surround action moving the cursor after cancelling previous one (#4780)
Fixes #4699
2020-05-06 16:06:11 -04:00
hetmankp
3b2a9e524e
Fix behaviour when pasting lines over selection (#3891)
Currently when pasting lines of text (i.e. text in register is linewise)
over an existing selection, the code incorrectly yanks the selected
lines of text into the register specified by the command. This is
incorrect behaviour as the selected text should always be yanked into
the unnamed register (or clipboard register if appropriate).

Fixes #2895, fixes #2939.
2020-05-06 15:54:45 -04:00
Jason Fields
f4c21f334d Fix flaky tests
Fixes #4801
2020-05-05 20:53:45 -04:00
Jason Fields
dc43ab92eb Fix a few issues with A in visual block mode
- Adds spaces when line isn't long enough (fixes #4795)
- Don't delete text when selection is on whitespace (fixes #4796)
- Works with multiple cursors
2020-05-04 17:41:34 -04:00
Gergely Tóth
9a265056ab
Fix insert mode remaps leaving behind a character (#4791)
Fix insert mode key remaps leaving characters behind. This happened due to the new historyTracker optimizations, where we don't add the new characters one by one to history, but rather just the first one and then the rest at the end.
Fixes #4787
2020-05-03 13:54:09 -04:00
Donough Liu
924688c1cb
Fix a bug of gq, Small refactor. (#4592)
Incorrect behaviour when cursor is in the middle of a line.
Refactor: indentation should be get in paragraph reflow rather than
being passed in as a parameter.
2020-05-02 16:35:48 -04:00
fujimoto kyosuke
c915239068
Fix cursor pos after executing J in visual mode (#4702) 2020-04-26 16:32:26 -04:00
Luis Herranz
e02453ac01
Add isJump to sneak actions (#4697)
When you do a search with vim-sneak, VSCodeVim doesn't save your
position and you can't go back to where you were before using .

This PR adds isJump to both sneak movements to fix that.

Fixes #4696.
2020-04-24 00:11:15 -04:00
fujimoto kyosuke
af3d04d0cf
Fix g~ (#4641)
* Implement "g~~"
* Add some tests in visual mode
* Support g~ in visual block mode
2020-04-17 20:26:50 -07:00
Gergely Tóth
2f2bf4b8e8
Fix inner motions cancel multicursors (#4729)
* Multicursor: when iterating the cursors to execute actions for each of them, we now temporarily replace the cursorStartPosition as well and update the given cursor
* Added tests for multicursor inner motions
2020-04-17 20:18:46 -07:00
fujimoto kyosuke
33f3c88a8e
Fix error when count exceeds max number of rows in "[count]Y/J" (#4628)
`Position.getDown()` does bounds-checking, so it prevents going past the document's end.
2020-03-30 10:55:17 -04:00
Jason Fields
38db172d13 More refactor (primarily of Position) 2020-03-29 15:06:47 -04:00
fujimoto kyosuke
6e7b766e22
Fix J command in visual block mode when cursor stop is before start (#4691) 2020-03-27 11:20:07 -04:00
Alexandre Grison
eefae96460
Implement vim-textobj-entire (#4580)
This PR implements two text-objects from the vim-textobj-entire plugin

This Vim plugin adds two useful text-objects:

ae which represents the entire content of a buffer
ie which represents the entire content of a buffer without the leading and trailing spaces.
You can then use gUae to transform the whole text buffer content in uppercase, whereas normally you would have to use gggUG.

This text-object has the advantage that you can use it from anywhere your cursor is currently located, you don't have to be conscious of the cursor position.

Fixes #3379
2020-03-26 14:53:50 -04:00
renovate[bot]
b6d75ca49a
Update dependency prettier to v2 (#4661)
All line endings are now unix-style (\n), and arrow functions always have parentheses around their parameters.
2020-03-26 13:02:33 -04:00
Jason Fields
824dda5c60
Optimize HistoryTracker using a cached TextDocument.version (#4681)
This replaces `mightChangeDocument`, which sought to do the same sort of optimization in a less effective and far more clumsy way.
Fixes #4665
2020-03-26 11:49:21 -04:00