Skip to content

Commit 41915c1

Browse files
authored
remote - avoid multiple codicons when high latency (microsoft#183525)
1 parent d939e5d commit 41915c1

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/vs/workbench/contrib/remote/browser/remoteIndicator.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export class RemoteStatusIndicator extends Disposable implements IWorkbenchContr
437437
}
438438

439439
private renderRemoteStatusIndicator(initialText: string, initialTooltip?: string | MarkdownString, command?: string, showProgress?: boolean): void {
440-
const { text, tooltip, ariaLabel } = this.withNetworkStatus(initialText, initialTooltip);
440+
const { text, tooltip, ariaLabel } = this.withNetworkStatus(initialText, initialTooltip, showProgress);
441441

442442
const properties: IStatusbarEntry = {
443443
name: nls.localize('remoteHost', "Remote Host"),
@@ -457,35 +457,37 @@ export class RemoteStatusIndicator extends Disposable implements IWorkbenchContr
457457
}
458458
}
459459

460-
private withNetworkStatus(initialText: string, initialTooltip?: string | MarkdownString): { text: string; tooltip: string | IMarkdownString | undefined; ariaLabel: string } {
460+
private withNetworkStatus(initialText: string, initialTooltip?: string | MarkdownString, showProgress?: boolean): { text: string; tooltip: string | IMarkdownString | undefined; ariaLabel: string } {
461461
let text = initialText;
462462
let tooltip = initialTooltip;
463463
let ariaLabel = getCodiconAriaLabel(text);
464464

465-
// `initialText` can have a "$(remote)" codicon in the beginning
466-
// but it may not have it depending on the environment.
467-
// the following function will replace the codicon in the beginning with
468-
// another icon or add it to the beginning if no icon
465+
function textWithAlert(): string {
469466

470-
function insertOrReplaceCodicon(target: string, codicon: string): string {
471-
if (target.startsWith('$(remote)')) {
472-
return target.replace('$(remote)', codicon);
467+
// `initialText` can have a codicon in the beginning that already
468+
// indicates some kind of status, or we may have been asked to
469+
// show progress, where a spinning codicon appears. we only want
470+
// to replace with an alert icon for when a normal remote indicator
471+
// is shown.
472+
473+
if (!showProgress && initialText.startsWith('$(remote)')) {
474+
return initialText.replace('$(remote)', '$(alert)');
473475
}
474476

475-
return `${codicon} ${target}`;
477+
return initialText;
476478
}
477479

478480
switch (this.networkState) {
479481
case 'offline': {
480-
text = insertOrReplaceCodicon(initialText, '$(alert)');
481-
482482
const offlineMessage = nls.localize('networkStatusOfflineTooltip', "Network appears to be offline, certain features might be unavailable.");
483+
484+
text = textWithAlert();
483485
tooltip = this.appendTooltipLine(tooltip, offlineMessage);
484486
ariaLabel = `${ariaLabel}, ${offlineMessage}`;
485487
break;
486488
}
487489
case 'high-latency':
488-
text = insertOrReplaceCodicon(initialText, '$(alert)');
490+
text = textWithAlert();
489491
tooltip = this.appendTooltipLine(tooltip, nls.localize('networkStatusHighLatencyTooltip', "Network appears to have high latency ({0}ms last, {1}ms average), certain features may be slow to respond.", remoteConnectionLatencyMeasurer.latency?.current?.toFixed(2), remoteConnectionLatencyMeasurer.latency?.average?.toFixed(2)));
490492
break;
491493
}

0 commit comments

Comments
 (0)