Skip to content

Commit

Permalink
Use partial parsing for stylesheets for Emmet command #43470
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Mar 27, 2018
1 parent d22af8f commit f5b569b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/emmet/src/abbreviationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';
import { Node, HtmlNode, Rule, Property, Stylesheet } from 'EmmetNode';
import { getEmmetHelper, getNode, getInnerRange, getMappingForIncludedLanguages, parseDocument, validate, getEmmetConfiguration, isStyleSheet, getEmmetMode } from './util';
import { getEmmetHelper, getNode, getInnerRange, getMappingForIncludedLanguages, parseDocument, validate, getEmmetConfiguration, isStyleSheet, getEmmetMode, parsePartialStylesheet } from './util';

const trimRegex = /[\u00a0]*[\d|#|\-|\*|\u2022]+\.?/;
const hexColorRegex = /^#\d+$/;
Expand Down Expand Up @@ -227,8 +227,12 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined
}

const editor = vscode.window.activeTextEditor;

let rootNode = parseDocument(editor.document, false);
let rootNode: Node | undefined;
if (editor.selections.length === 1 && isStyleSheet(editor.document.languageId) && editor.document.lineCount > 1000) {
rootNode = parsePartialStylesheet(editor.document, editor.selection.isReversed ? editor.selection.anchor : editor.selection.active);
} else {
rootNode = parseDocument(editor.document, false);
}

// When tabbed on a non empty selection, do not treat it as an emmet abbreviation, and fallback to tab instead
if (vscode.workspace.getConfiguration('emmet')['triggerExpansionOnTab'] === true && editor.selections.find(x => !x.isEmpty)) {
Expand Down

0 comments on commit f5b569b

Please sign in to comment.