提交 915e1eb8 编写于 作者: R Ramya Achutha Rao

Return if there was parsing error

上级 fc6c6931
......@@ -30,6 +30,9 @@ function balance(out: boolean) {
let getRangeFunction = out ? getRangeToBalanceOut : getRangeToBalanceIn;
let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
let newSelections: vscode.Selection[] = [];
editor.selections.forEach(selection => {
......
......@@ -17,6 +17,9 @@ export function matchTag() {
}
let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
let updatedSelections = [];
editor.selections.forEach(selection => {
let updatedSelection = getUpdatedSelections(editor, selection.start, rootNode);
......@@ -38,7 +41,8 @@ function getUpdatedSelections(editor: vscode.TextEditor, position: vscode.Positi
return;
}
let finalPosition = position.isBeforeOrEqual(currentNode.open.end) ? currentNode.close.start : currentNode.open.start;
// Place cursor inside the close tag if cursor is inside the open tag, else place it inside the open tag
let finalPosition = position.isBeforeOrEqual(currentNode.open.end) ? currentNode.close.start.translate(0, 2) : currentNode.open.start.translate(0, 1);
return new vscode.Selection(finalPosition, finalPosition);
}
......
......@@ -21,7 +21,9 @@ export function mergeLines() {
}
let rootNode: Node = parse(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
editor.edit(editBuilder => {
editor.selections.reverse().forEach(selection => {
let [rangeToReplace, textToReplaceWith] = getRangesToReplace(editor.document, selection, rootNode);
......
......@@ -35,6 +35,9 @@ export function fetchSelectItem(direction: string): void {
}
let rootNode: Node = parseContent(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
let newSelections: vscode.Selection[] = [];
editor.selections.forEach(selection => {
const selectionStart = selection.isReversed ? selection.active : selection.anchor;
......
......@@ -21,7 +21,9 @@ export function splitJoinTag() {
}
let rootNode: Node = parse(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
editor.edit(editBuilder => {
editor.selections.reverse().forEach(selection => {
let [rangeToReplace, textToReplaceWith] = getRangesToReplace(editor.document, selection, rootNode);
......
......@@ -41,7 +41,9 @@ export function toggleComment() {
}
let rootNode = parseContent(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
editor.edit(editBuilder => {
editor.selections.reverse().forEach(selection => {
let [rangesToUnComment, rangeToComment] = toggleCommentInternal(editor.document, selection, rootNode);
......
......@@ -17,6 +17,9 @@ export function updateTag(tagName: string) {
}
let rootNode: HtmlNode = parse(new DocumentStreamReader(editor.document));
if (!rootNode) {
return;
}
let rangesToUpdate = [];
editor.selections.reverse().forEach(selection => {
rangesToUpdate = rangesToUpdate.concat(getRangesToUpdate(editor, selection, rootNode));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册