Skip to content

Commit 9cbe3bb

Browse files
Mnehmosdaniel-lxs
authored andcommitted
Update DiffViewProvider.ts
No async / await: We don't need to await the timeout. We just want to schedule checkAndResolve to run in the future, not pause the entire function. setTimeout does this perfectly on its own. No if Statement: The confusing if statement is gone. We are no longer checking the return value because we don't need to do anything with it in this specific spot. The primary purpose here is just to trigger the check. Clear Intent: The corrected code is much clearer. Its only job is to kick off the checkAndResolve function after 100ms. This acts as a simple, manual trigger to supplement the main onDidChangeTabGroups event listener, which is the more robust part of the fix.
1 parent 9d4ab07 commit 9cbe3bb

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ export class DiffViewProvider {
393393
.map((tab) =>
394394
vscode.window.tabGroups.close(tab).then(
395395
() => undefined,
396-
(err) => {
397-
// Ignore errors when closing diff tabs - they may already be closed
398-
},
396+
(err) => {
397+
// Ignore errors when closing diff tabs - they may already be closed
398+
},
399399
),
400400
)
401401

@@ -479,11 +479,9 @@ export class DiffViewProvider {
479479
{ preserveFocus: true },
480480
)
481481
.then(
482-
async () => {
482+
() => {
483483
// Give a brief moment for the editor to appear in tab groups
484-
await new Promise((r) => setTimeout(r, 100))
485-
if (!checkAndResolve()) {
486-
}
484+
setTimeout(checkAndResolve, 100)
487485
},
488486
(err) => {
489487
if (timeoutId) clearTimeout(timeoutId)

0 commit comments

Comments
 (0)