Skip to content

Commit

Permalink
Protection for Symbol name
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Nov 24, 2016
1 parent 04bd618 commit 8a24025
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/providers/signatureHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { hasInFacts } from '../utils/facts';

// RegExp's
const reNestedParenthesis = /\(([\w-]+)\(/;
const reSymbolName = /[\w-]+$/;

interface IMixinEntry {
name: string;
Expand Down Expand Up @@ -52,7 +53,8 @@ function getSymbolName(text: string): string {
token = tokens[pos];

if (token[0] === 'word' && !hasInFacts(token[1])) {
return token[1] || null;
const match = reSymbolName.exec(token[1]);
return match ? match[0] : null;
}
}
} else if (token[0] === ')') {
Expand Down
8 changes: 8 additions & 0 deletions src/test/providers/signatureHelp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ describe('Providers/SignatureHelp - parseArgumentsAtLine for Functions', () => {
assert.ok(signatures[0].label.startsWith('make'), 'name');
});

it('Single-line Function reference', () => {
const doc = makeDocument('content: make()+make(');
const signatures = doSignatureHelp(doc, 21, cache, settings).signatures;

assert.equal(signatures.length, 1, 'length');
assert.ok(signatures[0].label.startsWith('make'), 'name');
});

it('Inside another uncompleted function', () => {
const doc = makeDocument('content: attr(make(');
const signatures = doSignatureHelp(doc, 19, cache, settings).signatures;
Expand Down

0 comments on commit 8a24025

Please sign in to comment.