diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 1eda53b86f9..6d74e778da6 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -3971,8 +3971,8 @@ abstract class IncrementDecrementNumberAction extends BaseCommand { for (let { start, end, word } of Position.IterateWords(whereToStart)) { // '-' doesn't count as a word, but is important to include in parsing - // the number - if (text[start.character - 1] === '-') { + // the number, as long as it is not just part of the word (-foo2 for example) + if (text[start.character - 1] === '-' && /\d/.test(text[start.character])) { start = start.getLeft(); word = text[start.character] + word; } diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts index fe6bb942582..ef7894127ce 100644 --- a/test/mode/modeNormal.test.ts +++ b/test/mode/modeNormal.test.ts @@ -1642,6 +1642,13 @@ suite('Mode Normal', () => { end: ['foo1bar|3'], }); + newTest({ + title: 'can on word with - in front of it', + start: ['-fo|o2'], + keysPressed: '', + end: ['-foo|3'], + }); + newTest({ title: 'can do Y', start: ['|blah blah'],