Getting closer to shared config #59803

This commit is contained in:
Ramya Achutha Rao
2018-10-02 20:00:19 -07:00
parent 5ae10c4ee3
commit 6ad61f018a
19 changed files with 128 additions and 122 deletions

View File

@@ -7,24 +7,13 @@ import * as vscode from 'vscode';
import { validate, parseDocument, isStyleSheet } from './util';
import { nextItemHTML, prevItemHTML } from './selectItemHTML';
import { nextItemStylesheet, prevItemStylesheet } from './selectItemStylesheet';
import { HtmlNode, CssNode } from 'EmmetNode';
export function fetchSelectItem(direction: string): void {
if (!validate() || !vscode.window.activeTextEditor) {
return;
}
const editor = vscode.window.activeTextEditor;
let nextItem: any;
let prevItem: any;
if (isStyleSheet(editor.document.languageId)) {
nextItem = nextItemStylesheet;
prevItem = prevItemStylesheet;
} else {
nextItem = nextItemHTML;
prevItem = prevItemHTML;
}
let rootNode = parseDocument(editor.document);
if (!rootNode) {
return;
@@ -35,7 +24,12 @@ export function fetchSelectItem(direction: string): void {
const selectionStart = selection.isReversed ? selection.active : selection.anchor;
const selectionEnd = selection.isReversed ? selection.anchor : selection.active;
let updatedSelection = direction === 'next' ? nextItem(selectionStart, selectionEnd, editor, rootNode) : prevItem(selectionStart, selectionEnd, editor, rootNode);
let updatedSelection;
if (isStyleSheet(editor.document.languageId)) {
updatedSelection = direction === 'next' ? nextItemStylesheet(selectionStart, selectionEnd, <CssNode>rootNode!) : prevItemStylesheet(selectionStart, selectionEnd, <CssNode>rootNode!);
} else {
updatedSelection = direction === 'next' ? nextItemHTML(selectionStart, selectionEnd, editor, <HtmlNode>rootNode!) : prevItemHTML(selectionStart, selectionEnd, editor, <HtmlNode>rootNode!);
}
newSelections.push(updatedSelection ? updatedSelection : selection);
});
editor.selections = newSelections;