mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 08:38:56 +01:00
Getting closer to shared config #59803
This commit is contained in:
@@ -19,14 +19,6 @@ export function toggleComment(): Thenable<boolean> | undefined {
|
||||
return;
|
||||
}
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
let toggleCommentInternal: (document: vscode.TextDocument, selection: vscode.Selection, rootNode: Node) => vscode.TextEdit[];
|
||||
|
||||
if (isStyleSheet(editor.document.languageId)) {
|
||||
toggleCommentInternal = toggleCommentStylesheet;
|
||||
} else {
|
||||
toggleCommentInternal = toggleCommentHTML;
|
||||
}
|
||||
|
||||
let rootNode = parseDocument(editor.document);
|
||||
if (!rootNode) {
|
||||
return;
|
||||
@@ -35,7 +27,7 @@ export function toggleComment(): Thenable<boolean> | undefined {
|
||||
return editor.edit(editBuilder => {
|
||||
let allEdits: vscode.TextEdit[][] = [];
|
||||
editor.selections.reverse().forEach(selection => {
|
||||
let edits = toggleCommentInternal(editor.document, selection, rootNode!);
|
||||
let edits = isStyleSheet(editor.document.languageId) ? toggleCommentStylesheet(selection, <Stylesheet>rootNode) : toggleCommentHTML(editor.document, selection, rootNode!);
|
||||
if (edits.length > 0) {
|
||||
allEdits.push(edits);
|
||||
}
|
||||
@@ -76,7 +68,7 @@ function toggleCommentHTML(document: vscode.TextDocument, selection: vscode.Sele
|
||||
let buffer = new DocumentStreamReader(document, startNode.open.end, new vscode.Range(startNode.open.end, startNode.close.start));
|
||||
let cssRootNode = parseStylesheet(buffer);
|
||||
|
||||
return toggleCommentStylesheet(document, selection, cssRootNode);
|
||||
return toggleCommentStylesheet(selection, cssRootNode);
|
||||
}
|
||||
|
||||
let allNodes: Node[] = getNodesInBetween(startNode, endNode);
|
||||
@@ -117,7 +109,7 @@ function getRangesToUnCommentHTML(node: Node, document: vscode.TextDocument): vs
|
||||
return unCommentTextEdits;
|
||||
}
|
||||
|
||||
function toggleCommentStylesheet(document: vscode.TextDocument, selection: vscode.Selection, rootNode: Stylesheet): vscode.TextEdit[] {
|
||||
function toggleCommentStylesheet(selection: vscode.Selection, rootNode: Stylesheet): vscode.TextEdit[] {
|
||||
let selectionStart = selection.isReversed ? selection.active : selection.anchor;
|
||||
let selectionEnd = selection.isReversed ? selection.anchor : selection.active;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user