Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
- name: Install dependencies
run: npm --color ci

- name: Run lint
run: npm --color run lint

- name: Read version from package.json
run: |
VERSION=$(node -p "require('./package.json').version")
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Install dependencies
run: npm --color ci

- name: Compile
run: npm --color run compile

- name: Run lint
run: npm --color run lint
2 changes: 1 addition & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export default eslintTs.config(
{
files: ["eslint.config.ts"],
extends: [eslintTs.configs.disableTypeChecked],
}
},
);
20 changes: 10 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const languages: Record<string, Language | undefined> = {
};

// For some reason this crashes if we put it inside activate
// TODO: this isn't a field, suppress package member coloring like Go
// Fix: this isn't a field, suppress package member coloring like Go
const initParser = treeSitter.Parser.init();

// Called when the extension is first activated by user opening a file with the appropriate language
Expand All @@ -87,7 +87,7 @@ export function activate(context: vscode.ExtensionContext) {
const validateGetLanguage = (languageId: string) => {
if (disabledLanguages?.has(languageId)) {
throw new Error(
`${languageId} is disabled on vscode versions >= 1.98.0. See https://github.com/cursorless-dev/cursorless/issues/2879`
`${languageId} is disabled on vscode versions >= 1.98.0. See https://github.com/cursorless-dev/cursorless/issues/2879`,
);
}
};
Expand Down Expand Up @@ -117,7 +117,7 @@ export function activate(context: vscode.ExtensionContext) {
absolute = path.join(
context.extensionPath,
"parsers",
language.module + ".wasm"
language.module + ".wasm",
);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ export function activate(context: vscode.ExtensionContext) {

function updateTree(
parser: treeSitter.Parser,
edit: vscode.TextDocumentChangeEvent
edit: vscode.TextDocumentChangeEvent,
) {
if (edit.contentChanges.length === 0) {
return;
Expand Down Expand Up @@ -239,20 +239,20 @@ export function activate(context: vscode.ExtensionContext) {
async function openIfVisible(document: vscode.TextDocument) {
if (
vscode.window.visibleTextEditors.some(
(editor) => editor.document.uri.toString() === document.uri.toString()
(editor) => editor.document.uri.toString() === document.uri.toString(),
)
) {
await open(document);
}
}

context.subscriptions.push(
vscode.window.onDidChangeVisibleTextEditors(colorAllOpen)
vscode.window.onDidChangeVisibleTextEditors(colorAllOpen),
);
context.subscriptions.push(vscode.workspace.onDidChangeTextDocument(edit));
context.subscriptions.push(vscode.workspace.onDidCloseTextDocument(close));
context.subscriptions.push(
vscode.workspace.onDidOpenTextDocument(openIfVisible)
vscode.workspace.onDidOpenTextDocument(openIfVisible),
);

// Don't wait for the initial color, it takes too long to inspect the themes and causes VSCode extension host to hang
Expand All @@ -263,7 +263,7 @@ export function activate(context: vscode.ExtensionContext) {

if (ret == null) {
const document = vscode.workspace.textDocuments.find(
(textDocument) => textDocument.uri.toString() === uri.toString()
(textDocument) => textDocument.uri.toString() === uri.toString(),
);

if (document == null) {
Expand Down Expand Up @@ -297,15 +297,15 @@ export function activate(context: vscode.ExtensionContext) {
*/
getLanguage(languageId: string): treeSitter.Language | undefined {
console.warn(
"vscode-parse-tree: getLanguage is deprecated, use createQuery(languageId, source) instead."
"vscode-parse-tree: getLanguage is deprecated, use createQuery(languageId, source) instead.",
);
validateGetLanguage(languageId);
return languages[languageId]?.parser?.language ?? undefined;
},

createQuery(
languageId: string,
source: string
source: string,
): treeSitter.Query | undefined {
const language = languages[languageId]?.parser?.language;
if (language == null) {
Expand Down