This command aims to be backward compatible with existing implementation of ctrl+backspace
a.k.a deleteWorldLeft
because existing ctrl+backspace
actually is a hungry delete on the same line with some optimizations
for source code editing.
In the previous version which supports only a single cursor, the code just invokes deleteWordLeft
command to delete the word before the cursor.
In order to support multiple cursors, I need to invoke each cursor to deleteWorldLeft
, but I can't find any API available so I write a mock implementation of deleteWorldLeft
.
As mentioned before, the existing ctrl+backspace
is a hungry delete inline with some optimizations. The examples use the following syntax to illustrates the ideas
- |: the cursor position
- => : (after pressing ctrl+backspace)
- Trivial : Trivial deleteWordLeft
- VSC: Visual Studio Code existing deleteWordLeft
- Current: Current implementation that is not the same as VSC
Visual Studio Code a.k.a VSC have configurable world separators (e.g. @ or =), which will be stopped in deleteWorldLeft
Example:
- Trivial: "This is @@myName|" => "This is |"
- VSC: "This is @@myName|" => "This is @@|"
Example:
- Trivial: "This is @@|" => "This is @|"
- VSC: "This is @@|" => "This is |"
Example 2:
- Trivial: "This is My@@|" => "This is |"
- VSC: "This is My@@|" => "This is My|"
Example 3: (This feature is not yet implemented)
- Trivial: "This is My@@==|" => "This is "
- VSC: "This is My@@==|" => "This is My|"
- Current: "This is My@@==|" => "This is My@@|" => => "This is My|"
If there is ONLY a white space before the cursor, VSC deleteWordLeft
will delete the whitespace with the previous word.
Example:
- Trivial: "This is |" => "This is|"
- VSC: "This is |" => "This |"
- Only can register the word pattern but it cannot be retrieved
After a few months I found out that the API actually can retrieve the word pattern, I think the current implementation is acceptable and I am lazy to change it, but I am welcome with the pull request.
- The word range is undefined when the cursor is placed at word separators