Skip to content

Commit 85f0578

Browse files
Merge pull request #9 from JonahFintzDev/8-feature-request-add-tags-to-results-like-wsl-etc
feat: add tag display to setting and page
2 parents 3b5fbb3 + 5d9a8ae commit 85f0578

File tree

6 files changed

+136
-6
lines changed

6 files changed

+136
-6
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ This project provides a command palette extension for opening Visual Studio Code
4545
- **Use Strict Search**: Enables or disables strict search for workspaces.
4646
- **Strict Search**: Matches items where the search text appears as a contiguous substring in the item's title or subtitle. For example, searching for "abc" will match "abc" or "abc123" but not "a1b2c3".
4747
- **Show Details Panel**: Toggles the visibility of the details panel in the UI.
48+
- **Tag Type**: Configures the tags displayed for each workspace.
49+
- Options:
50+
- **None**: No tags are displayed.
51+
- **Type**: Displays the workspace type (e.g., Local, WSL, Remote).
52+
- **Target**: Displays the target instance name (e.g., VS Code, VS Code Insider).
53+
- **Type & Target**: Displays both the workspace type and the target instance name.
4854

4955
## Contributing
5056

VsCode/Classes/SettingsManager.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,53 @@ public class SettingsManager : JsonSettingsManager
1515

1616
private static string Namespaced(string propertyName) => $"{_namespace}.{propertyName}";
1717

18-
private static readonly List<ChoiceSetSetting.Choice> _choices =
18+
private static readonly List<ChoiceSetSetting.Choice> _preferredEditionChoices =
1919
[
2020
new ChoiceSetSetting.Choice(Resource.setting_preferredEdition_option_default_label, "Default"),
2121
new ChoiceSetSetting.Choice(Resource.setting_preferredEdition_option_insider_label, "Insider"),
2222
];
2323

24+
private static readonly List<ChoiceSetSetting.Choice> _tagChoices =
25+
[
26+
new ChoiceSetSetting.Choice(Resource.setting_tagType_option_none_label, "None"),
27+
new ChoiceSetSetting.Choice(Resource.setting_tagType_option_type_label, "Type"),
28+
new ChoiceSetSetting.Choice(Resource.setting_tagType_option_target_label, "Target"),
29+
new ChoiceSetSetting.Choice(Resource.setting_tagType_option_typeandtarget_label, "TypeAndTarget"),
30+
];
31+
32+
2433

2534
private readonly ToggleSetting _useStrictSearch = new(
2635
Namespaced(nameof(UseStrichtSearch)),
2736
Resource.settings_useStrictSearch_label,
2837
Resource.settings_useStrictSearch_desc,
29-
false); // TODO -- double check default value
38+
false);
3039

3140
private readonly ToggleSetting _showDetails = new(
3241
Namespaced(nameof(ShowDetails)),
3342
Resource.settings_showDetails_label,
3443
Resource.settings_showDetails_desc,
35-
false); // TODO -- double check default value
44+
false);
3645

3746
private readonly ChoiceSetSetting _preferredEdition = new(
3847
Namespaced(nameof(PreferredEdition)),
3948
Resource.setting_preferredEdition_label,
4049
Resource.setting_preferredEdition_desc,
41-
_choices);
50+
_preferredEditionChoices);
51+
52+
53+
54+
private readonly ChoiceSetSetting _tagType = new(
55+
Namespaced(nameof(TagType)),
56+
Resource.setting_tagType_label,
57+
Resource.setting_tagType_desc,
58+
_tagChoices);
4259

4360
public bool UseStrichtSearch => _useStrictSearch.Value;
4461
public bool ShowDetails => _showDetails.Value;
4562

4663
public string PreferredEdition => _preferredEdition.Value ?? "Default";
64+
public string TagType => _tagType.Value ?? "Type";
4765

4866

4967
internal static string SettingsJsonPath()
@@ -61,6 +79,7 @@ public SettingsManager()
6179

6280
Settings.Add(_showDetails);
6381
Settings.Add(_useStrictSearch);
82+
Settings.Add(_tagType);
6483
Settings.Add(_preferredEdition);
6584

6685
// Load settings from file upon initialization

VsCode/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Identity
1313
Name="JonahFintzDEV.602808C55E867"
1414
Publisher="CN=240FD63B-E96D-4F79-A6D2-BFC6E6AD6C10"
15-
Version="1.2.0.0" />
15+
Version="1.3.0.0" />
1616

1717

1818
<Properties>

VsCode/Pages/VSCodePage.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,40 @@ public override IListItem[] GetItems()
4747
Metadata = workspace.GetMetadata(),
4848
};
4949

50-
items.Add(new ListItem(command) { Title = details.Title, Subtitle = Uri.UnescapeDataString(workspace.Path), Details = details, Icon = workspace.Instance.GetIcon() });
50+
var tags = new List<Tag>();
51+
52+
switch (_settingsManager.TagType)
53+
{
54+
case "None":
55+
break;
56+
case "Type":
57+
tags.Add(new Tag(workspace.GetWorkspaceType()));
58+
if (workspace.GetVSType() != "")
59+
{
60+
tags.Add(new Tag(workspace.GetVSType()));
61+
}
62+
break;
63+
case "Target":
64+
tags.Add(new Tag(workspace.Instance.Name));
65+
break;
66+
case "TypeAndTarget":
67+
tags.Add(new Tag(workspace.GetWorkspaceType()));
68+
if (workspace.GetVSType() != "")
69+
{
70+
tags.Add(new Tag(workspace.GetVSType()));
71+
}
72+
tags.Add(new Tag(workspace.Instance.Name));
73+
break;
74+
}
75+
76+
items.Add(new ListItem(command)
77+
{
78+
Title = details.Title,
79+
Subtitle = Uri.UnescapeDataString(workspace.Path),
80+
Details = details,
81+
Icon = workspace.Instance.GetIcon(),
82+
Tags = tags.ToArray()
83+
});
5184
}
5285

5386
if (items.Count == 0)

VsCode/Properties/Resource.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VsCode/Properties/Resource.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,22 @@
162162
<data name="settings_showDetails_desc" xml:space="preserve">
163163
<value>Details panel</value>
164164
</data>
165+
<data name="setting_tagType_label" xml:space="preserve">
166+
<value>Tags</value>
167+
</data>
168+
<data name="setting_tagType_desc" xml:space="preserve">
169+
<value>Displayed tags</value>
170+
</data>
171+
<data name="setting_tagType_option_none_label" xml:space="preserve">
172+
<value>-</value>
173+
</data>
174+
<data name="setting_tagType_option_type_label" xml:space="preserve">
175+
<value>Type</value>
176+
</data>
177+
<data name="setting_tagType_option_target_label" xml:space="preserve">
178+
<value>Target</value>
179+
</data>
180+
<data name="setting_tagType_option_typeandtarget_label" xml:space="preserve">
181+
<value>Type &amp; Target</value>
182+
</data>
165183
</root>

0 commit comments

Comments
 (0)