Skip to content

Commit a263627

Browse files
Merge pull request #21 from JonahFintzDev/20-dismiss-or-hide-the-command-palette-after-picking-a-project-to-open
feat: add command result settings and update OpenVSCodeCommand behavior
2 parents 9a55929 + cec93d4 commit a263627

File tree

7 files changed

+160
-48
lines changed

7 files changed

+160
-48
lines changed

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ This project provides a command palette extension for opening Visual Studio Code
2424
</a>
2525

2626
### Via Command Palette
27+
2728
1. Open Command Palette
2829
2. Select "Command Palette - VS Code"
2930

3031
### Via Winget
32+
3133
1. Open Command Prompt or PowerShell
3234
2. Run the following command:
3335
```bash
@@ -42,15 +44,39 @@ This project provides a command palette extension for opening Visual Studio Code
4244
## Settings
4345

4446
- **Preferred Edition**: Determines which edition (Default or Insider) is used when a folder or workspace has been opened in both editions of VS Code.
45-
- **Use Strict Search**: Enables or disables strict search for workspaces.
47+
- Options:
48+
- **Default**: Uses the standard VS Code edition
49+
- **Insider**: Uses the VS Code Insider edition
50+
- **Use Strict Search**: Enables or disables strict search for workspaces.
4651
- **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".
4752
- **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+
- **Tags**: Configures the tags displayed for each workspace.
54+
- Options:
55+
- **None** (-): No tags are displayed.
56+
- **Type**: Displays the workspace type (e.g., Local, WSL, Remote).
57+
- **Target**: Displays the target instance name (e.g., VS Code, VS Code Insider).
5358
- **Type & Target**: Displays both the workspace type and the target instance name.
59+
- **Command Result Action**: Determines what should happen after opening a VS Code workspace.
60+
- Options:
61+
- **Dismiss**: Closes the Command Palette after opening the workspace
62+
- **Go Back**: Returns to the previous Command Palette view
63+
- **Keep Open**: Keeps the Command Palette open after opening the workspace
64+
65+
## Technical Information
66+
67+
- **Version**: 1.6.0.0
68+
- **Target Framework**: .NET 9.0 (Windows 10.0.22621.0)
69+
- **Minimum OS Version**: Windows 10 (10.0.19041.0)
70+
- **Architecture Support**: x64, ARM64
71+
- **Package Type**: MSIX (Microsoft Store app)
72+
73+
## Project Structure
74+
75+
- **Main Application**: [`CmdPalVsCode.cs`](VsCode/CmdPalVsCode.cs) - Main extension implementation
76+
- **Commands Provider**: [`CmdPalVsCodeCommandsProvider.cs`](VsCode/CmdPalVsCodeCommandsProvider.cs) - Command palette provider
77+
- **Settings Management**: [`SettingsManager.cs`](VsCode/Classes/SettingsManager.cs) - Handles user preferences
78+
- **VS Code Integration**: [`OpenVsCodeCommand.cs`](VsCode/Commands/OpenVsCodeCommand.cs) - Command execution logic
79+
- **UI Pages**: [`VSCodePage.cs`](VsCode/Pages/VSCodePage.cs) - Main interface page
5480

5581
## Contributing
5682

VsCode/Classes/SettingsManager.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ public class SettingsManager : JsonSettingsManager
2929
new ChoiceSetSetting.Choice(Resource.setting_tagType_option_typeandtarget_label, "TypeAndTarget"),
3030
];
3131

32+
private static readonly List<ChoiceSetSetting.Choice> _commandResultChoices =
33+
[
34+
new ChoiceSetSetting.Choice(Resource.setting_commandResult_option_dismiss_label, "Dismiss"),
35+
new ChoiceSetSetting.Choice(Resource.setting_commandResult_option_goback_label, "GoBack"),
36+
new ChoiceSetSetting.Choice(Resource.setting_commandResult_option_keepopen_label, "KeepOpen"),
37+
];
38+
3239

3340

3441
private readonly ToggleSetting _useStrictSearch = new(
@@ -57,11 +64,18 @@ public class SettingsManager : JsonSettingsManager
5764
Resource.setting_tagType_desc,
5865
_tagChoices);
5966

67+
private readonly ChoiceSetSetting _commandResult = new(
68+
Namespaced(nameof(CommandResult)),
69+
Resource.setting_commandResult_label,
70+
Resource.setting_commandResult_desc,
71+
_commandResultChoices);
72+
6073
public bool UseStrichtSearch => _useStrictSearch.Value;
6174
public bool ShowDetails => _showDetails.Value;
6275

6376
public string PreferredEdition => _preferredEdition.Value ?? "Default";
6477
public string TagType => _tagType.Value ?? "Type";
78+
public string CommandResult => _commandResult.Value ?? "Dismiss";
6579

6680

6781
internal static string SettingsJsonPath()
@@ -81,6 +95,7 @@ public SettingsManager()
8195
Settings.Add(_useStrictSearch);
8296
Settings.Add(_tagType);
8397
Settings.Add(_preferredEdition);
98+
Settings.Add(_commandResult);
8499

85100
// Load settings from file upon initialization
86101
LoadSettings();

VsCode/Commands/OpenVsCodeCommand.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ internal sealed partial class OpenVSCodeCommand : InvokableCommand
1111
private string workspacePath;
1212
private string executablePath;
1313
private VSCodePage page;
14+
private string commandResult;
1415

1516
/// <summary>
1617
/// Initializes a new instance of the <see cref="OpenVSCodeCommand"/> class.
1718
/// </summary>
1819
/// <param name="executablePath">The path to the VS Code executable.</param>
1920
/// <param name="workspacePath">The path to the workspace to open.</param>
20-
public OpenVSCodeCommand(string executablePath, string workspacePath, VSCodePage page)
21+
/// <param name="page">The VS Code page instance.</param>
22+
/// <param name="commandResult">The command result setting value.</param>
23+
public OpenVSCodeCommand(string executablePath, string workspacePath, VSCodePage page, string commandResult)
2124
{
2225
this.workspacePath = workspacePath;
2326
this.executablePath = executablePath;
2427
this.page = page;
28+
this.commandResult = commandResult;
2529
}
2630

2731
/// <summary>
@@ -42,13 +46,20 @@ public override CommandResult Invoke()
4246
}
4347

4448
ShellHelpers.OpenInShell(executablePath, arguments, null, ShellHelpers.ShellRunAsType.None, false);
45-
46-
// reset search text
47-
page.UpdateSearchText(page.SearchText, "");
48-
page.SearchText = "";
49-
5049
VSCodePage.LoadItems = true;
5150

52-
return CommandResult.GoHome();
51+
switch (commandResult)
52+
{
53+
case "GoBack":
54+
return CommandResult.GoBack();
55+
case "KeepOpen":
56+
// reset search text
57+
page.UpdateSearchText(page.SearchText, "");
58+
page.SearchText = "";
59+
return CommandResult.KeepOpen();
60+
case "Dismiss":
61+
default:
62+
return CommandResult.Dismiss();
63+
}
5364
}
5465
}

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.5.0.0" />
15+
Version="1.6.0.0" />
1616

1717
<Properties>
1818
<DisplayName>Command Palette - VS Code</DisplayName>

VsCode/Pages/VSCodePage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void InitializeItemList()
4343
foreach (var workspace in workspaces)
4444
{
4545
// add instance to the list
46-
var command = new OpenVSCodeCommand(workspace.Instance.ExecutablePath, workspace.Path, this);
46+
var command = new OpenVSCodeCommand(workspace.Instance.ExecutablePath, workspace.Path, this, _settingsManager.CommandResult);
4747

4848
Details details = new Details()
4949
{

0 commit comments

Comments
 (0)