summaryrefslogtreecommitdiff
path: root/extension/src/continueIdeClient.ts
diff options
context:
space:
mode:
authorMark Percival <m@mdp.im>2023-08-02 13:35:24 +0000
committerMark Percival <m@mdp.im>2023-08-02 13:54:55 +0000
commite129ab412f3372d65cb9ee5bc251f8810e91c5c6 (patch)
treef1c40dfe7c501392dd63aa1e07f618510920c83f /extension/src/continueIdeClient.ts
parentc4d88a8d22622d7c63ca19ba1945dd82dbc3e008 (diff)
downloadsncontinue-e129ab412f3372d65cb9ee5bc251f8810e91c5c6.tar.gz
sncontinue-e129ab412f3372d65cb9ee5bc251f8810e91c5c6.tar.bz2
sncontinue-e129ab412f3372d65cb9ee5bc251f8810e91c5c6.zip
Fix: Don't ignore files with numbers in the basename
Diffstat (limited to 'extension/src/continueIdeClient.ts')
-rw-r--r--extension/src/continueIdeClient.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index 498cf9de..b0fb9e8d 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -125,7 +125,7 @@ class IdeProtocolClient {
// Setup listeners for any selection changes in open editors
vscode.window.onDidChangeTextEditorSelection((event) => {
- if (this.editorIsTerminal(event.textEditor)) {
+ if (!this.editorIsCode(event.textEditor)) {
return;
}
if (this._highlightDebounce) {
@@ -426,17 +426,19 @@ class IdeProtocolClient {
// ------------------------------------ //
// Respond to request
- private editorIsTerminal(editor: vscode.TextEditor) {
- return (
- !!path.basename(editor.document.uri.fsPath).match(/\d/) ||
- (editor.document.languageId === "plaintext" &&
- editor.document.getText() === "accessible-buffer-accessible-buffer-")
+ // Checks to see if the editor is a code editor.
+ // In some cases vscode.window.visibleTextEditors can return non-code editors
+ // e.g. terminal editors in side-by-side mode
+ private editorIsCode(editor: vscode.TextEditor) {
+ return !(
+ editor.document.languageId === "plaintext" &&
+ editor.document.getText() === "accessible-buffer-accessible-buffer-"
);
}
getOpenFiles(): string[] {
return vscode.window.visibleTextEditors
- .filter((editor) => !this.editorIsTerminal(editor))
+ .filter((editor) => this.editorIsCode(editor))
.map((editor) => {
return editor.document.uri.fsPath;
});
@@ -444,7 +446,7 @@ class IdeProtocolClient {
getVisibleFiles(): string[] {
return vscode.window.visibleTextEditors
- .filter((editor) => !this.editorIsTerminal(editor))
+ .filter((editor) => this.editorIsCode(editor))
.map((editor) => {
return editor.document.uri.fsPath;
});
@@ -452,7 +454,7 @@ class IdeProtocolClient {
saveFile(filepath: string) {
vscode.window.visibleTextEditors
- .filter((editor) => !this.editorIsTerminal(editor))
+ .filter((editor) => this.editorIsCode(editor))
.forEach((editor) => {
if (editor.document.uri.fsPath === filepath) {
editor.document.save();
@@ -463,7 +465,7 @@ class IdeProtocolClient {
readFile(filepath: string): string {
let contents: string | undefined;
vscode.window.visibleTextEditors
- .filter((editor) => !this.editorIsTerminal(editor))
+ .filter((editor) => this.editorIsCode(editor))
.forEach((editor) => {
if (editor.document.uri.fsPath === filepath) {
contents = editor.document.getText();
@@ -509,7 +511,7 @@ class IdeProtocolClient {
// TODO
let rangeInFiles: RangeInFile[] = [];
vscode.window.visibleTextEditors
- .filter((editor) => !this.editorIsTerminal(editor))
+ .filter((editor) => this.editorIsCode(editor))
.forEach((editor) => {
editor.selections.forEach((selection) => {
// if (!selection.isEmpty) {