-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFallbackWorkspaceItem.cs
More file actions
57 lines (48 loc) · 1.7 KB
/
Copy pathFallbackWorkspaceItem.cs
File metadata and controls
57 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Modifications copyright (c) 2025 tanchekwei
// Licensed under the MIT License. See the LICENSE file in the project root for details.
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.ApplicationModel;
using WorkspaceLauncherForVSCode.Classes;
using WorkspaceLauncherForVSCode.Enums;
using WorkspaceLauncherForVSCode.Interfaces;
using WorkspaceLauncherForVSCode.Workspaces;
namespace WorkspaceLauncherForVSCode.Pages;
internal sealed partial class FallbackWorkspaceItem : FallbackCommandItem
{
private readonly VisualStudioCodePage _page;
private readonly int _index;
public FallbackWorkspaceItem(
VisualStudioCodePage page,
int index)
: base(new NoOpCommand(),
$"{Constant.VisualStudioCodeDisplayName} fallback result no. {index + 1}",
$"{Package.Current.Id.Name}.{nameof(FallbackWorkspaceItem)}.{index}")
{
Icon = Classes.Icon.VisualStudioAndVisualStudioCode;
_page = page;
_index = index;
}
public override void UpdateQuery(string query)
{
Command = new NoOpCommand();
Title = string.Empty;
Subtitle = string.Empty;
Icon = null;
if (string.IsNullOrWhiteSpace(query) || _page.AllWorkspaces.Count == 0)
{
return;
}
var filtered = _page.GetFallbackFilteredWorkspaces(query);
if (filtered.Count <= _index)
{
return;
}
var best = filtered[_index];
var listItem = _page.GetOrCreateListItem(best, true);
Title = listItem.Title;
Subtitle = listItem.Subtitle;
Icon = listItem.Icon;
Command = listItem.Command;
MoreCommands = listItem.MoreCommands;
}
}