提交 1b4886dd 编写于 作者: G Gus Hurovich 提交者: Ramya Rao

Adding setting for disabling partial parsing in stylesheets (#46979)

* Adding setting for disabling partial parsing in stylesheets

* Added description
上级 ea90500f
...@@ -211,6 +211,11 @@ ...@@ -211,6 +211,11 @@
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "%emmetShowSuggestionsAsSnippets%" "description": "%emmetShowSuggestionsAsSnippets%"
},
"emmet.optimizeStylesheetParsing": {
"type": "boolean",
"default": true,
"description": "%emmetOptimizeStylesheetParsing%"
} }
} }
}, },
......
...@@ -53,5 +53,6 @@ ...@@ -53,5 +53,6 @@
"emmetPreferencesCssMozProperties": "Comma separated CSS properties that get the 'moz' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'moz' prefix.", "emmetPreferencesCssMozProperties": "Comma separated CSS properties that get the 'moz' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'moz' prefix.",
"emmetPreferencesCssOProperties": "Comma separated CSS properties that get the 'o' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'o' prefix.", "emmetPreferencesCssOProperties": "Comma separated CSS properties that get the 'o' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'o' prefix.",
"emmetPreferencesCssMsProperties": "Comma separated CSS properties that get the 'ms' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'ms' prefix.", "emmetPreferencesCssMsProperties": "Comma separated CSS properties that get the 'ms' vendor prefix when used in Emmet abbreviation that starts with `-`. Set to empty string to always avoid the 'ms' prefix.",
"emmetPreferencesCssFuzzySearchMinScore": "The minimum score (from 0 to 1) that fuzzy-matched abbreviation should achieve. Lower values may produce many false-positive matches, higher values may reduce possible matches." "emmetPreferencesCssFuzzySearchMinScore": "The minimum score (from 0 to 1) that fuzzy-matched abbreviation should achieve. Lower values may produce many false-positive matches, higher values may reduce possible matches.",
"emmetOptimizeStylesheetParsing": "When set to false, the whole file is parsed to determine if current position is valid for expanding Emmet abbreviations. When set to true, only the content around the current position in css/scss/less files is parsed."
} }
...@@ -228,7 +228,8 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined ...@@ -228,7 +228,8 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined
const editor = vscode.window.activeTextEditor; const editor = vscode.window.activeTextEditor;
let rootNode: Node | undefined; let rootNode: Node | undefined;
if (editor.selections.length === 1 && isStyleSheet(editor.document.languageId) && editor.document.lineCount > 1000) { let usePartialParsing = vscode.workspace.getConfiguration('emmet')['optimizeStylesheetParsing'] === true;
if (editor.selections.length === 1 && isStyleSheet(editor.document.languageId) && usePartialParsing && editor.document.lineCount > 1000) {
rootNode = parsePartialStylesheet(editor.document, editor.selection.isReversed ? editor.selection.anchor : editor.selection.active); rootNode = parsePartialStylesheet(editor.document, editor.selection.isReversed ? editor.selection.anchor : editor.selection.active);
} else { } else {
rootNode = parseDocument(editor.document, false); rootNode = parseDocument(editor.document, false);
......
...@@ -40,7 +40,8 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi ...@@ -40,7 +40,8 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
validateLocation = syntax === 'html' || isStyleSheet(document.languageId); validateLocation = syntax === 'html' || isStyleSheet(document.languageId);
// If document can be css parsed, get currentNode // If document can be css parsed, get currentNode
if (isStyleSheet(document.languageId)) { if (isStyleSheet(document.languageId)) {
rootNode = document.lineCount > 1000 ? parsePartialStylesheet(document, position) : <Stylesheet>parseDocument(document, false); let usePartialParsing = vscode.workspace.getConfiguration('emmet')['optimizeStylesheetParsing'] === true;
rootNode = usePartialParsing && document.lineCount > 1000 ? parsePartialStylesheet(document, position) : <Stylesheet>parseDocument(document, false);
if (!rootNode) { if (!rootNode) {
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册