Skip to content

Commit 10bc84c

Browse files
authored
fix: DH-21833: Fixed issue with localhost labels (#310)
Fixes a bug where the label for first configured localhost server was used for all localhost connections. ### Before fix: Both connections (neither of them being 4010 server) show 4010 on the connection since it is the first configured server. <img width="601" height="70" alt="image" src="https://github.com/user-attachments/assets/5eda4ff5-fb79-482a-91f4-cbff0f1c2ee3" /> <img width="315" height="314" alt="image" src="https://github.com/user-attachments/assets/f9aa1beb-81f6-4d11-8b0f-8478d0c9ce56" /> ### After fix: <img width="321" height="326" alt="image" src="https://github.com/user-attachments/assets/ea0ac51f-dca5-4daf-83a3-115aabbb3ceb" />
1 parent 78a1f3c commit 10bc84c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/providers/ServerConnectionPanelTreeProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
sortByStringProp,
1313
} from '../util';
1414
import { getFirstSupportedConsoleType } from '../services';
15+
import { getServerMatchPortIfLocalHost } from '../mcp/utils';
1516

1617
export class ServerConnectionPanelTreeProvider extends ServerTreeProviderBase<ServerConnectionPanelNode> {
1718
constructor(serverManager: IServerManager, panelService: IPanelService) {
@@ -32,9 +33,9 @@ export class ServerConnectionPanelTreeProvider extends ServerTreeProviderBase<Se
3233
return getPanelVariableTreeItem(connectionOrVariable);
3334
}
3435

35-
const serverLabel = this.serverManager.getServer(
36-
connectionOrVariable.serverUrl,
37-
false
36+
const serverLabel = getServerMatchPortIfLocalHost(
37+
this.serverManager,
38+
connectionOrVariable.serverUrl
3839
)?.label;
3940

4041
return getPanelConnectionTreeItem(

src/providers/ServerConnectionTreeProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
} from '../types';
99
import { isInstanceOf, sortByStringProp } from '../util';
1010
import { DhcService } from '../services';
11+
import { getServerMatchPortIfLocalHost } from '../mcp/utils';
1112

1213
/**
1314
* Provider for the server connection tree view.
@@ -48,9 +49,9 @@ export class ServerConnectionTreeProvider extends ServerTreeProviderBase<ServerC
4849

4950
const hasUris = this.serverManager.hasConnectionUris(connectionOrUri);
5051

51-
const serverLabel = this.serverManager.getServer(
52-
connectionOrUri.serverUrl,
53-
false
52+
const serverLabel = getServerMatchPortIfLocalHost(
53+
this.serverManager,
54+
connectionOrUri.serverUrl
5455
)?.label;
5556

5657
const label = serverLabel ?? connectionOrUri.serverUrl.host;

0 commit comments

Comments
 (0)