Skip to content

Commit 9f4774b

Browse files
committed
More concisely remove item from array
1 parent 0a603a7 commit 9f4774b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/nova_deno.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ function registerEditorWatcher() {
146146
}));
147147

148148
disposable.add(editor.onDidDestroy((deletedEditor) => {
149-
const editors: (TextEditor | null)[] = [...nova.workspace.textEditors];
149+
// TODO: remember what this copy is for
150+
const editors = [...nova.workspace.textEditors];
150151

151152
// remove one editor whose URI is the same as this editor's
152-
const index = (editors as TextEditor[]).findIndex((editor) =>
153-
editor.document.uri == deletedEditor.document.uri
153+
const index = (editors as TextEditor[]).findIndex(
154+
(editor) => editor.document.uri === deletedEditor.document.uri,
154155
);
155-
editors[index] = null;
156-
const remainingEditors = editors.filter((editor) =>
157-
editor !== null
158-
) as TextEditor[];
159-
const remainingDocuments = remainingEditors.map((editor) =>
160-
editor.document
156+
const remainingEditors = editors.filter(
157+
(_editor, editorIndex) => editorIndex !== index,
161158
);
162159

160+
const remainingDocuments = remainingEditors.map(
161+
(editor) => editor.document,
162+
);
163163
checkFeatureAvailability(remainingDocuments);
164164
}));
165165
}),

0 commit comments

Comments
 (0)