Skip to content

Commit

Permalink
Up the version
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Feb 7, 2018
1 parent 59b9c55 commit 0036874
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-emmet-helper",
"version": "1.1.24",
"version": "1.1.25",
"description": "Helper to use emmet modules in Visual Studio Code",
"main": "./out/emmetHelper.js",
"types": "./out/emmetHelper.d.ts",
Expand Down
57 changes: 24 additions & 33 deletions src/emmetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export function isStyleSheet(syntax): boolean {
return (stylesheetSyntaxes.indexOf(syntax) > -1);
}

function getFilters (text: string, pos: number) : {pos: number, filter: string} {
function getFilters(text: string, pos: number): { pos: number, filter: string } {
let filter;
for (let i = 0; i < maxFilters; i++) {
if (text.endsWith(`${filterDelimitor}${bemFilterSuffix}`, pos)) {
Expand All @@ -371,52 +371,43 @@ function getFilters (text: string, pos: number) : {pos: number, filter: string}
* Extracts abbreviation from the given position in the given document
*/
export function extractAbbreviation(document: TextDocument, position: Position, lookAhead: boolean = true) {
let currentLine = getCurrentLine(document, position);
let currentLineTillPosition = currentLine.substr(0, position.character);

let {pos, filter} = getFilters(currentLineTillPosition, position.character);
const currentLine = getCurrentLine(document, position);
const currentLineTillPosition = currentLine.substr(0, position.character);
const { pos, filter } = getFilters(currentLineTillPosition, position.character);
const lengthOccupiedByFilter = filter ? filter.length + 1 : 0;

let lengthOccupiedByFilter = filter ? filter.length + 1 : 0;
let result;
try {
result = extract(currentLine, pos, lookAhead);
const result = extract(currentLine, pos, lookAhead);
const rangeToReplace = Range.create(position.line, result.location, position.line, result.location + result.abbreviation.length + lengthOccupiedByFilter);
return {
abbreviationRange: rangeToReplace,
abbreviation: result.abbreviation,
filter
};
}
catch (e) {
}
if (!result) {
return null;
}
let rangeToReplace = Range.create(position.line, result.location, position.line, result.location + result.abbreviation.length + lengthOccupiedByFilter);
return {
abbreviationRange: rangeToReplace,
abbreviation: result.abbreviation,
filter
};
}

/**
* Extracts abbreviation from the given text
*/
export function extractAbbreviationFromText(text: string): any {
let filter;
if (!text) {
return {
abbreviation: '',
filter
}
return;
}
let pos;
({pos, filter} = getFilters(text, text.length));
let result;

const { pos, filter } = getFilters(text, text.length);

try {
result = extract(text, pos, true);
const result = extract(text, pos, true);
return {
abbreviation: result.abbreviation,
filter
};
}
catch (e) {
}
if (!result) {
return null;
}
return {
abbreviation: result.abbreviation,
filter
};
}

/**
Expand Down

0 comments on commit 0036874

Please sign in to comment.