Skip to content

Commit

Permalink
Reformat context.subscriptions.push()
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCMD committed Feb 6, 2025
1 parent c6f3637 commit 2aca736
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
10 changes: 3 additions & 7 deletions src/TreeSitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ export async function initTreeSitter(context: vscode.ExtensionContext) {
return;
}
parseTextDocument(document);
})
);
}),

context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument(edits => {
// vscode.window.showInformationMessage(JSON.stringify("change"));
const document = edits.document;
Expand Down Expand Up @@ -312,10 +310,8 @@ export async function initTreeSitter(context: vscode.ExtensionContext) {
reason: activeDocument.edits?.reason,
};
// vscode.window.showInformationMessage(JSON.stringify(activeDocument.edits));
})
);
}),

context.subscriptions.push(
vscode.workspace.onDidCloseTextDocument(document => {
// vscode.window.showInformationMessage(JSON.stringify("close"));
const uriString = document.uri.toString();
Expand All @@ -325,7 +321,7 @@ export async function initTreeSitter(context: vscode.ExtensionContext) {
trees[uriString].regexTrees.clear();
delete trees[uriString];
}
})
}),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ export async function getPackageJSON(baseUri: vscode.TextDocument | vscode.Uri,
const packageUri2 = vscode.Uri.joinPath(uri, ...pathSegments, '..', 'package.json'); // Maybe grammar file is at the same level as `package.json`

const file1 = await vscode.workspace.fs.readFile(packageUri1).then(null, () => { });
const packageUri = file1 ? packageUri1 : packageUri2;

const file = file1 || await vscode.workspace.fs.readFile(packageUri2).then(null, () => { });
if (!file) {
return {};
}

const packageUri = file1 ? packageUri1 : packageUri2;

try {
const decoder = new TextDecoder(); // Works in VSCode web
const text = decoder.decode(file);
Expand Down
34 changes: 11 additions & 23 deletions src/tokenColorCustomizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ export function initTokenColorCustomizations(context: vscode.ExtensionContext) {
// vscode.window.showInformationMessage(JSON.stringify("active"));
const document = editor?.document; // `editor` can be `undefined`!
update(packageJSON(document) || jsonTextMate(document));
})
);

context.subscriptions.push(
}),
vscode.workspace.onDidOpenTextDocument((document: vscode.TextDocument) => {
// vscode.window.showInformationMessage(JSON.stringify("open"));
if (document == vscode.window.activeTextEditor?.document) { // `activeTextEditor` can be `undefined`!
update(packageJSON(document) || jsonTextMate(document));
}
})
);

context.subscriptions.push(
}),
vscode.workspace.onDidChangeTextDocument((edits: vscode.TextDocumentChangeEvent) => {
// vscode.window.showInformationMessage(JSON.stringify("change"));
if (edits.contentChanges.length == 0) {
Expand All @@ -36,26 +30,20 @@ export function initTokenColorCustomizations(context: vscode.ExtensionContext) {
update(packageJSON(document));
}
}
})
);

// context.subscriptions.push(
// vscode.workspace.onDidChangeConfiguration((event: vscode.ConfigurationChangeEvent) => {
// // vscode.window.showInformationMessage(JSON.stringify("config"));
// if (event.affectsConfiguration("editor.tokenColorCustomizations")) {
// const document = vscode.window.activeTextEditor?.document; // `activeTextEditor` can be `undefined`!
// update(packageJSON(document) || jsonTextMate(document));
// }
// })
// );

context.subscriptions.push(
}),
// vscode.workspace.onDidChangeConfiguration((event: vscode.ConfigurationChangeEvent) => {
// // vscode.window.showInformationMessage(JSON.stringify("config"));
// if (event.affectsConfiguration("editor.tokenColorCustomizations")) {
// const document = vscode.window.activeTextEditor?.document; // `activeTextEditor` can be `undefined`!
// update(packageJSON(document) || jsonTextMate(document));
// }
// }),
vscode.workspace.onDidCloseTextDocument((document: vscode.TextDocument) => {
// vscode.window.showInformationMessage(JSON.stringify("close"));
if (document == vscode.window.activeTextEditor?.document) { // `activeTextEditor` can be `undefined`!
update(undefined);
}
})
}),
);
}

Expand Down

0 comments on commit 2aca736

Please sign in to comment.