Skip to content

Commit 7b69abd

Browse files
committed
Adds trackable tab helper
1 parent 3ad0291 commit 7b69abd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/system/-webview/vscode/tabs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Tab } from 'vscode';
22
import { Uri, window } from 'vscode';
33
import { areUrisEqual } from '../../uri';
4+
import { isTrackableUri } from './uris';
45

56
export function getTabUri(tab: Tab | undefined): Uri | undefined {
67
const input = tab?.input;
@@ -44,6 +45,11 @@ export function getVisibleTabs(uri: Uri): Tab[] {
4445
.sort((a, b) => (a.group.isActive ? -1 : 1) - (b.group.isActive ? -1 : 1));
4546
}
4647

48+
export function isTrackableTab(tab: Tab | undefined): boolean {
49+
const uri = getTabUri(tab);
50+
return uri != null ? isTrackableUri(uri) : false;
51+
}
52+
4753
export function tabContainsUri(tab: Tab | undefined, uri: Uri | undefined): boolean {
4854
if (uri == null) return false;
4955

src/system/-webview/vscode/uris.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export async function openUrl(url?: string): Promise<boolean | undefined> {
2020
// vscode.d.ts currently says it only supports a Uri, but it actually accepts a string too
2121
return (env.openExternal as unknown as (target: string) => Thenable<boolean>)(url);
2222
}
23+
2324
export function isTrackableUri(uri: Uri): boolean {
2425
return trackableSchemes.has(uri.scheme as Schemes);
2526
}
27+
2628
export function isVirtualUri(uri: Uri): boolean {
2729
return uri.scheme === Schemes.Virtual || uri.scheme === Schemes.GitHub;
2830
}

src/views/nodes/lineHistoryTrackerNode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode<
139139
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
140140
return { cancel: !updated };
141141
}
142+
142143
@debug()
143144
protected async subscribe(): Promise<Disposable | undefined> {
144145
await this.updateUri();
145-
146146
if (this.view.container.lineTracker.subscribed(this)) return undefined;
147147

148148
const onActiveLinesChanged = debounce(this.onActiveLinesChanged.bind(this), 250);
@@ -172,6 +172,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode<
172172
private onActiveLinesChanged(_e: LinesChangeEvent) {
173173
void this.triggerChange();
174174
}
175+
175176
@gate()
176177
@log()
177178
async changeBase(): Promise<void> {

0 commit comments

Comments
 (0)