Skip to content

Commit cf59194

Browse files
committed
Renames isHost method
1 parent d8c5208 commit cf59194

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

src/webviews/plus/graph/graphWebview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
478478
registerCommands(): Disposable[] {
479479
const commands: Disposable[] = [];
480480

481-
if (this.host.isHost('view')) {
481+
if (this.host.is('view')) {
482482
commands.push(
483483
registerCommand(`${this.host.id}.refresh`, () => this.host.refresh(true)),
484484
registerCommand(
@@ -1076,7 +1076,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
10761076
},
10771077
);
10781078

1079-
const details = this.host.isHost('editor')
1079+
const details = this.host.is('editor')
10801080
? this.container.views.commitDetails
10811081
: this.container.views.graphDetails;
10821082
if (!details.ready) {
@@ -1712,7 +1712,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
17121712
this._selection = commits;
17131713

17141714
if (commits == null) return;
1715-
if (!this._firstSelection && this.host.isHost('editor') && !this.host.active) return;
1715+
if (!this._firstSelection && this.host.is('editor') && !this.host.active) return;
17161716

17171717
this.container.events.fire(
17181718
'commit:selected',
@@ -3353,7 +3353,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
33533353
const ref = this.getGraphItemRef(item, 'revision');
33543354
if (ref == null) return Promise.resolve();
33553355

3356-
if (this.host.isHost('view')) {
3356+
if (this.host.is('view')) {
33573357
return void showGraphDetailsView(ref, { preserveFocus: true, preserveVisibility: false });
33583358
}
33593359

src/webviews/plus/patchDetails/patchDetailsWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class PatchDetailsWebviewProvider
219219
registerCommands(): Disposable[] {
220220
const commands: Disposable[] = [];
221221

222-
if (this.host.isHost('view')) {
222+
if (this.host.is('view')) {
223223
commands.push(
224224
registerCommand(`${this.host.id}.refresh`, () => this.host.refresh(true)),
225225
registerCommand(`${this.host.id}.close`, () => this.closeView()),

src/webviews/plus/timeline/timelineWebview.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
105105
etagSubscription: this.container.subscription.etag,
106106
};
107107

108-
if (this.host.isHost('view')) {
108+
if (this.host.is('view')) {
109109
this.host.description = proBadge;
110110
}
111111
}
@@ -165,15 +165,15 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
165165
uri = arg.uri;
166166
} else if (isSerializedState<State>(arg)) {
167167
this._context.config = { ...this._context.config, ...arg.state.config };
168-
if (this.host.isHost('editor')) {
168+
if (this.host.is('editor')) {
169169
uri = arg.state.uri != null ? Uri.parse(arg.state.uri) : undefined;
170170
}
171171
}
172172
}
173173

174174
uri ??= await ensureWorkingUri(this.container, this.activeTabUri);
175175
await this.updateUri(uri, true);
176-
if (this.host.isHost('editor')) {
176+
if (this.host.is('editor')) {
177177
this.fireFileSelected();
178178
}
179179

@@ -193,7 +193,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
193193
registerCommands(): Disposable[] {
194194
const commands: Disposable[] = [];
195195

196-
if (this.host.isHost('view')) {
196+
if (this.host.is('view')) {
197197
commands.push(
198198
registerCommand(`${this.host.id}.refresh`, () => this.host.refresh(true), this),
199199
registerCommand(
@@ -213,7 +213,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
213213
}
214214

215215
onActiveChanged(active: boolean): void {
216-
if (active && this.host.isHost('editor')) {
216+
if (active && this.host.is('editor')) {
217217
this.fireFileSelected();
218218
}
219219
}
@@ -228,7 +228,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
228228

229229
this._repositorySubscription?.resume();
230230

231-
if (this.host.isHost('editor')) {
231+
if (this.host.is('editor')) {
232232
this._disposable = Disposable.from(
233233
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
234234
);
@@ -493,7 +493,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
493493
const repository: State['repository'] =
494494
repo != null ? { id: repo.id, uri: repo.uri.toString(), name: repo.name, ref: ref } : undefined;
495495

496-
if (this.host.isHost('editor')) {
496+
if (this.host.is('editor')) {
497497
this.host.title = `Visual ${itemType === 'folder' ? 'Folder' : 'File'} History${title ? `: ${title}` : ''}`;
498498
} else {
499499
this.host.description = title || proBadge;
@@ -653,7 +653,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
653653
preview: true,
654654
// Since the multi-diff editor doesn't support choosing the view column, we need to do it manually so passing in our view column
655655
sourceViewColumn: this.host.viewColumn,
656-
viewColumn: this.host.isHost('view') ? undefined : ViewColumn.Beside,
656+
viewColumn: this.host.is('view') ? undefined : ViewColumn.Beside,
657657
title: `Folder Changes in ${shortenRevision(commit.sha, {
658658
strings: { working: 'Working Tree' },
659659
})}`,
@@ -670,7 +670,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
670670
preview: true,
671671
// Since the multi-diff editor doesn't support choosing the view column, we need to do it manually so passing in our view column
672672
sourceViewColumn: this.host.viewColumn,
673-
viewColumn: this.host.isHost('view') ? undefined : ViewColumn.Beside,
673+
viewColumn: this.host.is('view') ? undefined : ViewColumn.Beside,
674674
title: `Folder Changes in ${shortenRevision(commit.sha, {
675675
strings: { working: 'Working Tree' },
676676
})}`,
@@ -690,7 +690,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
690690
void openTextEditor(uri, {
691691
preserveFocus: true,
692692
preview: true,
693-
viewColumn: this.host.isHost('view') ? undefined : ViewColumn.Beside,
693+
viewColumn: this.host.is('view') ? undefined : ViewColumn.Beside,
694694
});
695695

696696
break;
@@ -700,13 +700,13 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
700700
await openChanges(uri, commit, {
701701
preserveFocus: true,
702702
preview: true,
703-
viewColumn: this.host.isHost('view') ? undefined : ViewColumn.Beside,
703+
viewColumn: this.host.is('view') ? undefined : ViewColumn.Beside,
704704
});
705705
} else {
706706
await openChangesWithWorking(uri, commit, {
707707
preserveFocus: true,
708708
preview: true,
709-
viewColumn: this.host.isHost('view') ? undefined : ViewColumn.Beside,
709+
viewColumn: this.host.is('view') ? undefined : ViewColumn.Beside,
710710
});
711711
}
712712

src/webviews/webviewController.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,17 @@ export class WebviewController<
249249
'context.webview.id': this.id,
250250
'context.webview.type': this.descriptor.type,
251251
'context.webview.instanceId': this.instanceId,
252-
'context.webview.host': this.isHost('editor') ? 'editor' : 'view',
252+
'context.webview.host': this.is('editor') ? 'editor' : 'view',
253253
};
254254
}
255255

256-
isHost(
256+
is(
257257
type: 'editor',
258258
): this is WebviewPanelController<ID extends WebviewIds ? ID : never, State, SerializedState, ShowingArgs>;
259-
isHost(
259+
is(
260260
type: 'view',
261261
): this is WebviewViewController<ID extends WebviewViewIds ? ID : never, State, SerializedState, ShowingArgs>;
262-
isHost(
262+
is(
263263
type: 'editor' | 'view',
264264
): this is
265265
| WebviewPanelController<ID extends WebviewIds ? ID : never, State, SerializedState, ShowingArgs>
@@ -319,14 +319,14 @@ export class WebviewController<
319319
options?: WebviewShowOptions,
320320
...args: WebviewShowingArgs<ShowingArgs, SerializedState>
321321
): boolean | undefined {
322-
if (!this.isHost('editor')) return undefined;
322+
if (!this.is('editor')) return undefined;
323323

324324
if (options?.column != null && options.column !== this.parent.viewColumn) return false;
325325
return this.provider.canReuseInstance?.(...args);
326326
}
327327

328328
getSplitArgs(): WebviewShowingArgs<ShowingArgs, SerializedState> {
329-
if (this.isHost('view')) return [];
329+
if (this.is('view')) return [];
330330

331331
return this.provider.getSplitArgs?.() ?? [];
332332
}
@@ -376,14 +376,14 @@ export class WebviewController<
376376
}
377377
}
378378

379-
if (this.isHost('editor')) {
379+
if (this.is('editor')) {
380380
if (!loading) {
381381
this.parent.reveal(
382382
options.column ?? this.parent.viewColumn ?? this.descriptor.column ?? ViewColumn.Beside,
383383
options.preserveFocus ?? false,
384384
);
385385
}
386-
} else if (this.isHost('view')) {
386+
} else if (this.is('view')) {
387387
await executeCoreCommand(`${this.id}.focus`, options);
388388
if (loading) {
389389
this.provider.onVisibilityChanged?.(true);
@@ -616,7 +616,7 @@ export class WebviewController<
616616
this._cspNonce,
617617
this.asWebviewUri(this.getRootUri()).toString(),
618618
this.getWebRoot(),
619-
this.isHost('editor') ? 'editor' : 'view',
619+
this.is('editor') ? 'editor' : 'view',
620620
bootstrap,
621621
head,
622622
body,
@@ -760,7 +760,7 @@ export class WebviewController<
760760

761761
let success;
762762

763-
if (this.isHost('view')) {
763+
if (this.is('view')) {
764764
// If we are in a view, show progress if we are waiting too long
765765
const result = await pauseOnCancelOrTimeout(promise, undefined, 100);
766766
if (result.paused) {

src/webviews/webviewProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export interface WebviewHost<ID extends WebviewIds | WebviewViewIds> {
8282
sendPendingIpcNotifications(): void;
8383

8484
getTelemetryContext(): WebviewTelemetryContext;
85-
isHost(type: 'editor'): this is WebviewHost<ID extends WebviewIds ? ID : never>;
86-
isHost(type: 'view'): this is WebviewHost<ID extends WebviewViewIds ? ID : never>;
85+
is(type: 'editor'): this is WebviewHost<ID extends WebviewIds ? ID : never>;
86+
is(type: 'view'): this is WebviewHost<ID extends WebviewViewIds ? ID : never>;
8787

8888
notify<T extends IpcNotification<unknown>>(
8989
notificationType: T,

0 commit comments

Comments
 (0)