Skip to content

Commit 1f6549c

Browse files
committed
enhance: only show workspace name in window title in taskbar when there're multiple workspaces (#1966)
Signed-off-by: leo <longshuang@msn.cn>
1 parent d580f7f commit 1f6549c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ViewModels/Launcher.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Text;
34

45
using Avalonia.Collections;
56
using Avalonia.Threading;
@@ -467,10 +468,14 @@ private void CloseRepositoryInTab(LauncherPage page, bool removeFromWorkspace =
467468

468469
private void UpdateTitle()
469470
{
470-
if (_activeWorkspace == null)
471-
return;
471+
var builder = new StringBuilder(512);
472+
if (_activeWorkspace != null)
473+
{
474+
var workspaces = Preferences.Instance.Workspaces;
475+
if (workspaces.Count == 0 || workspaces.Count > 1 || workspaces[0] != _activeWorkspace)
476+
builder.Append('[').Append(_activeWorkspace.Name).Append("] ");
477+
}
472478

473-
var workspace = _activeWorkspace.Name;
474479
if (_activePage is { Data: Repository })
475480
{
476481
var node = _activePage.Node;
@@ -485,12 +490,14 @@ private void UpdateTitle()
485490
path = $"~{path.AsSpan(prefixLen)}";
486491
}
487492

488-
Title = $"[{workspace}] {name} ({path})";
493+
builder.Append(name).Append(" (").Append(path).Append(')');
489494
}
490495
else
491496
{
492-
Title = $"[{workspace}] Repositories";
497+
builder.Append("Repositories");
493498
}
499+
500+
Title = builder.ToString();
494501
}
495502

496503
private Workspace _activeWorkspace = null;

0 commit comments

Comments
 (0)