Skip to content

Commit

Permalink
watch active text editor to decide whether to create a global session
Browse files Browse the repository at this point in the history
  • Loading branch information
nhedger committed Oct 13, 2024
1 parent f2c4e1a commit f4077bc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,20 @@ export const createGlobalSessionWhenNecessary = async () => {
// If the editor has open Untitled documents, or VS Code User Data documents,
// we create a global session immeditaley so that the user can work with them.
if (
isEnabledGlobally() &&
(hasUntitledDocuments() || hasVSCodeUserDataDocuments())
(isEnabledGlobally() &&
window.activeTextEditor?.document.uri.scheme === "untitled") ||
window.activeTextEditor?.document.uri.scheme === "vscode-userdata"
) {
await createGlobalSessionIfNotExists();
}

// Register a listener for text documents being opened so that we can create
// a global session if necessary.
workspace.onDidOpenTextDocument(async (document) => {
window.onDidChangeActiveTextEditor(async (editor) => {
debug("Active text editor changed.", {
editor: editor?.document.uri.fsPath,
});
if (
isEnabledGlobally() &&
(hasUntitledDocuments() || hasVSCodeUserDataDocuments())
editor?.document.uri.scheme === "untitled" ||
editor?.document.uri.scheme === "vscode-userdata"
) {
await createGlobalSessionIfNotExists();
}
Expand Down

0 comments on commit f4077bc

Please sign in to comment.