Skip to content

Commit d5eeca2

Browse files
committed
Tests for workspace symbols
1 parent b1d491b commit d5eeca2

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

extension/test/electron/symbols/document-symbols.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function findDocumentSymbols(documentUri) {
2828
return result;
2929
}
3030

31-
test('gets CSS selectors', async () => {
31+
test('gets document symbols', async () => {
3232
const result = await findDocumentSymbols(stylesUri);
3333

3434
assert.ok(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$from-other: 'hello';
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const assert = require('node:assert');
2+
const path = require('node:path');
3+
const vscode = require('vscode');
4+
const { showFile, sleepCI } = require('../util');
5+
6+
const stylesUri = vscode.Uri.file(
7+
path.resolve(__dirname, 'fixtures', 'styles.sass')
8+
);
9+
10+
before(async () => {
11+
await showFile(stylesUri);
12+
await sleepCI();
13+
});
14+
15+
after(async () => {
16+
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
17+
});
18+
19+
/**
20+
* @param {string} [query='']
21+
* @returns {Promise<import('vscode').SymbolInformation[]>}
22+
*/
23+
async function findWorkspaceSymbols(query = '') {
24+
const result = await vscode.commands.executeCommand(
25+
'vscode.executeWorkspaceSymbolProvider',
26+
query
27+
);
28+
return result;
29+
}
30+
31+
test('gets workspace symbols with empty query', async () => {
32+
const result = await findWorkspaceSymbols();
33+
34+
assert.ok(result.find((s) => s.name === '.hello'));
35+
assert.ok(result.find((s) => s.name === '$from-other'));
36+
});
37+
38+
test('gets workspace symbols with query', async () => {
39+
const result = await findWorkspaceSymbols('other');
40+
41+
assert.equal(
42+
result.find((s) => s.name === '.hello'),
43+
undefined
44+
);
45+
46+
assert.ok(result.find((s) => s.name === '$from-other'));
47+
});

pkgs/sass_language_server/lib/src/language_server.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ class LanguageServer {
292292
var query =
293293
(params.value as Map<String, Object?>)['query'] as String?;
294294

295+
if (initialScan != null) {
296+
await initialScan;
297+
}
298+
295299
var result = _ls.findWorkspaceSymbols(query);
296300
return result;
297301
} on Exception catch (e) {

0 commit comments

Comments
 (0)