Skip to content

Commit 6077b24

Browse files
committed
Updated deps
1 parent 82496f7 commit 6077b24

File tree

8 files changed

+39
-281
lines changed

8 files changed

+39
-281
lines changed

package-lock.json

+23-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
"typescript": "^3.9.2"
2828
},
2929
"dependencies": {
30-
"@emmetio/action-utils": "^1.0.5",
30+
"@emmetio/action-utils": "^1.1.1",
3131
"@emmetio/css-matcher": "^1.0.2",
32-
"@emmetio/html-matcher": "^1.2.3",
32+
"@emmetio/html-matcher": "^1.3.0",
3333
"@emmetio/math-expression": "^1.0.4",
3434
"@emmetio/scanner": "^1.0.0",
35-
"emmet": "^2.0.2"
35+
"emmet": "^2.1.0"
3636
},
3737
"mocha": {
3838
"require": "./test/register",

src/abbreviation/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function initAbbreviationTracker(editor: TextEditor) {
3737
const pos = getCaret(ed);
3838
let tracker = handleChange(ed);
3939

40-
if (!tracker && lastPos !== null && lastPos === pos - 1 && allowTracking(ed, pos)) {
40+
if (!tracker && lastPos !== null && lastPos === pos - 1 && allowTracking(ed)) {
4141
tracker = startAbbreviationTracking(ed, pos);
4242
}
4343

@@ -62,7 +62,7 @@ export default function initAbbreviationTracker(editor: TextEditor) {
6262
/**
6363
* Check if abbreviation tracking is allowed in editor at given location
6464
*/
65-
function allowTracking(editor: TextEditor, pos: number): boolean {
65+
function allowTracking(editor: TextEditor): boolean {
6666
if (isEnabled()) {
6767
const syntax = docSyntax(editor);
6868
return isSupported(syntax) || isJSX(syntax);
@@ -222,9 +222,9 @@ function getActivationContext(editor: TextEditor, pos: number): UserConfig | und
222222
options: getOutputOptions(editor, pos)
223223
};
224224
}
225+
} else {
226+
return { syntax, type: 'markup' };
225227
}
226-
227-
return { syntax, type: 'markup' };
228228
}
229229

230230
function getCSSActivationContext(editor: TextEditor, pos: number, syntax: string, ctx: CSSContext): UserConfig | undefined {

src/lib/syntax.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { TokenType } from '@emmetio/css-matcher';
44
import { getHTMLContext, CSSContext, HTMLContext, getCSSContext } from '@emmetio/action-utils';
55
import { getContent, attributeValue, last } from './utils';
66

7-
const markupSyntaxes = ['html', 'xml', 'xsl', 'jsx', 'haml', 'jade', 'pug', 'slim'];
8-
const stylesheetSyntaxes = ['css', 'scss', 'sass', 'less', 'sss', 'stylus', 'postcss'];
97
const xmlSyntaxes = ['xml', 'xsl', 'jsx'];
10-
const htmlSyntaxes = ['html', 'vue'];
8+
const htmlSyntaxes = ['html', 'vue', 'html+erb', 'php'];
119
const cssSyntaxes = ['css', 'scss', 'less'];
1210
const jsxSyntaxes = ['jsx', 'tsx'];
11+
const markupSyntaxes = ['haml', 'jade', 'pug', 'slim'].concat(htmlSyntaxes, xmlSyntaxes, jsxSyntaxes);
12+
const stylesheetSyntaxes = ['sass', 'sss', 'stylus', 'postcss'].concat(cssSyntaxes);
1313

1414
export interface SyntaxInfo {
1515
type: SyntaxType;

src/main.ts

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import './actions/split-join-tag';
1212
import './actions/update-image-size';
1313
import './actions/wrap-with-abbreviation';
1414
import initAbbreviationTracker from './abbreviation';
15+
import { stopTracking } from './abbreviation/AbbreviationTracker';
1516
import createAutocompleteProvider from './autocomplete';
1617

1718
export function activate() {
@@ -20,3 +21,7 @@ export function activate() {
2021
nova.workspace.onDidAddTextEditor(initAbbreviationTracker);
2122
nova.assistants.registerCompletionAssistant('*', autocomplete);
2223
}
24+
25+
export function deactivate() {
26+
nova.workspace.textEditors.forEach(editor => stopTracking(editor, true));
27+
}

test/autocomplete.ts

+1-105
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import { AbbreviationContext } from 'emmet';
4-
import { deepStrictEqual as deepEqual, strictEqual as equal } from 'assert';
1+
import { strictEqual as equal } from 'assert';
52
import Range from './assets/range';
63
import createSimulator from './assets/simutator';
74
import { IssueCollection, Issue, IssueSeverity } from './assets/issue';
85
import nova from './assets/nova';
9-
import { getHTMLContext, getCSSContext } from '../src/lib/context';
106
import { startTracking, getTracker, handleChange, handleSelectionChange } from '../src/abbreviation/AbbreviationTracker';
117

12-
function read(fileName: string): string {
13-
const absPath = path.resolve(__dirname, fileName);
14-
return fs.readFileSync(absPath, 'utf8');
15-
}
16-
17-
function context(name: string, attributes?: { [name: string]: string }): AbbreviationContext {
18-
const result = { name } as AbbreviationContext;
19-
if (attributes) {
20-
result.attributes = attributes;
21-
}
22-
return result;
23-
}
24-
258
describe('Autocomplete provider', () => {
269
before(() => {
2710
global['Range'] = Range;
@@ -38,93 +21,6 @@ describe('Autocomplete provider', () => {
3821
delete global['nova'];
3922
});
4023

41-
it('HTML context', () => {
42-
const html = read('./samples/embedded-style.html');
43-
44-
deepEqual(getHTMLContext(html, 298), {
45-
syntax: 'html',
46-
context: context('div', { style: 'padding: 10px;' })
47-
});
48-
// Inside tag, ignore context
49-
deepEqual(getHTMLContext(html, 276), undefined);
50-
51-
// Inside tag but in `style` attribute value: syntax is `css` but no context
52-
// since caret is inside property name
53-
deepEqual(getHTMLContext(html, 286), {
54-
syntax: 'css',
55-
inline: true
56-
});
57-
58-
// Same as above but caret is inside CSS property value
59-
deepEqual(getHTMLContext(html, 290), {
60-
syntax: 'css',
61-
inline: true,
62-
context: context('padding')
63-
});
64-
deepEqual(getHTMLContext(html, 292), {
65-
syntax: 'css',
66-
inline: true,
67-
context: context('padding')
68-
});
69-
70-
// Inside empty `style` attribute
71-
deepEqual(getHTMLContext(html, 351), {
72-
syntax: 'css',
73-
inline: true
74-
});
75-
});
76-
77-
it('CSS in HTML', () => {
78-
const html = read('./samples/embedded-style.html');
79-
80-
// Inside <style> tag, inside selector block
81-
deepEqual(getHTMLContext(html, 212), {
82-
syntax: 'css'
83-
});
84-
85-
// Outside selector block
86-
deepEqual(getHTMLContext(html, 194), undefined);
87-
88-
// Inside property value
89-
deepEqual(getHTMLContext(html, 224), {
90-
syntax: 'css',
91-
context: context('padding')
92-
});
93-
});
94-
95-
it('CSS context', () => {
96-
const scss = read('./samples/style.scss');
97-
const ctx = (context?: {}) => {
98-
const result: any = { syntax: 'css' };
99-
if (context) {
100-
result.context = context;
101-
}
102-
103-
return result;
104-
};
105-
106-
// Not inside selector block
107-
deepEqual(getCSSContext(scss, 9), undefined);
108-
109-
// ...but inside property (variable)
110-
deepEqual(getCSSContext(scss, 5), ctx({ name: '$foo' }));
111-
112-
// Inside selector
113-
deepEqual(getCSSContext(scss, 12), undefined);
114-
115-
// Inside selector block
116-
deepEqual(getCSSContext(scss, 36), ctx());
117-
118-
// Inside property value
119-
deepEqual(getCSSContext(scss, 32), ctx({ name: 'padding' }));
120-
121-
// Still inside selector block
122-
deepEqual(getCSSContext(scss, 125), ctx());
123-
124-
// Not inside selector
125-
deepEqual(getCSSContext(scss, 128), undefined);
126-
});
127-
12824
it('abbreviation tracker', () => {
12925
const { editor, content, input, select } = createSimulator('before d after', 8, {
13026
onChange: handleChange,

0 commit comments

Comments
 (0)