Emmet: Locate number even when there is a selection Fixes #31281

This commit is contained in:
Ramya Achutha Rao
2017-07-23 16:37:30 -07:00
parent ecdeaf3ffd
commit 9b6cc9f774

View File

@@ -22,9 +22,9 @@ export function incrementDecrement(delta: number): Thenable<boolean> {
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;