Skip to content

Commit 9956be4

Browse files
committed
feat: add command result settings and update OpenVSCodeCommand behavior
1 parent 9a55929 commit 9956be4

File tree

6 files changed

+128
-42
lines changed

6 files changed

+128
-42
lines changed

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
{

VsCode/Properties/Resource.Designer.cs

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

0 commit comments

Comments
 (0)