From 9b6cc9f774f424b4e8a91d4a2d3d4ad8efb9cfb9 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Sun, 23 Jul 2017 16:37:30 -0700 Subject: [PATCH] Emmet: Locate number even when there is a selection Fixes #31281 --- extensions/emmet/src/incrementDecrement.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/emmet/src/incrementDecrement.ts b/extensions/emmet/src/incrementDecrement.ts index 378d2fbb11982..4459639d309b2 100644 --- a/extensions/emmet/src/incrementDecrement.ts +++ b/extensions/emmet/src/incrementDecrement.ts @@ -22,9 +22,9 @@ export function incrementDecrement(delta: number): Thenable { return editor.edit(editBuilder => { editor.selections.forEach(selection => { - let rangeToReplace: vscode.Range = selection; - if (selection.isEmpty) { - rangeToReplace = locate(editor.document, selection.isReversed ? selection.anchor : selection.active); + let rangeToReplace = locate(editor.document, selection.isReversed ? selection.anchor : selection.active); + if (!rangeToReplace) { + return; } const text = editor.document.getText(rangeToReplace); @@ -67,7 +67,7 @@ export function update(numString, delta): string { * @param {Point} pos * @return {Range} Range of number or `undefined` if not found */ -export function locate(document: vscode.TextDocument, pos: vscode.Position) { +export function locate(document: vscode.TextDocument, pos: vscode.Position): vscode.Range { const line = document.lineAt(pos.line).text; let start = pos.character;