Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Nodejs/Product/Nodejs/Nodejs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="UnifiedSettings.pkgdef">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="UnifiedSettings\NodejsGeneralOptions.registration.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<ZipItem Include="Templates\Files\JestUnitTest\UnitTest.js" />
<ZipItem Include="Templates\Files\JestUnitTest\UnitTest.vstemplate" />
<Content Include="Workspace\OpenFolderSchema.json">
Expand Down
75 changes: 65 additions & 10 deletions Nodejs/Product/Nodejs/Options/NodejsGeneralOptionsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class NodejsGeneralOptionsPage : NodejsDialogPage
private const string CheckForLongPathsSetting = "CheckForLongPaths";

private NodejsGeneralOptionsControl _window;
private bool _waitOnAbnormalExit;
private bool _waitOnNormalExit;
private bool _editAndContinue;
private bool _waitOnAbnormalExitModified;
private bool _waitOnNormalExitModified;
private bool _editAndContinueModified;

public NodejsGeneralOptionsPage()
: base("General")
Expand All @@ -38,18 +44,42 @@ protected override IWin32Window Window
/// True if Node processes should pause for input before exiting
/// if they exit abnormally.
/// </summary>
public bool WaitOnAbnormalExit { get; set; }
public bool WaitOnAbnormalExit
{
get => this._waitOnAbnormalExit;
set
{
this._waitOnAbnormalExit = value;
this._waitOnAbnormalExitModified = true;
}
}

/// <summary>
/// True if Node processes should pause for input before exiting
/// if they exit normally.
/// </summary>
public bool WaitOnNormalExit { get; set; }
public bool WaitOnNormalExit
{
get => this._waitOnNormalExit;
set
{
this._waitOnNormalExit = value;
this._waitOnNormalExitModified = true;
}
}

/// <summary>
/// Indicates whether Edit and Continue feature should be enabled.
/// </summary>
public bool EditAndContinue { get; set; }
public bool EditAndContinue
{
get => this._editAndContinue;
set
{
this._editAndContinue = value;
this._editAndContinueModified = true;
}
}

/// <summary>
/// Resets settings back to their defaults. This should be followed by
Expand All @@ -65,12 +95,36 @@ public override void ResetSettings()

public override void LoadSettingsFromStorage()
{
// Load settings from storage.
this.WaitOnAbnormalExit = LoadBool(WaitOnAbnormalExitSetting) ?? true;
this.WaitOnNormalExit = LoadBool(WaitOnNormalExitSetting) ?? false;
this.EditAndContinue = LoadBool(EditAndContinueSetting) ?? true;
this._waitOnAbnormalExit = LoadBool(WaitOnAbnormalExitSetting) ?? true;
this._waitOnNormalExit = LoadBool(WaitOnNormalExitSetting) ?? false;
this._editAndContinue = LoadBool(EditAndContinueSetting) ?? true;
this._waitOnAbnormalExitModified = false;
this._waitOnNormalExitModified = false;
this._editAndContinueModified = false;

if (this._window != null)
{
this._window.SyncControlWithPageSettings(this);
}
}

internal void RefreshSettingsFromStorage()
{
if (!this._waitOnAbnormalExitModified)
{
this._waitOnAbnormalExit = LoadBool(WaitOnAbnormalExitSetting) ?? true;
}

if (!this._waitOnNormalExitModified)
{
this._waitOnNormalExit = LoadBool(WaitOnNormalExitSetting) ?? false;
}

if (!this._editAndContinueModified)
{
this._editAndContinue = LoadBool(EditAndContinueSetting) ?? true;
}

// Synchronize UI with backing properties.
if (this._window != null)
{
this._window.SyncControlWithPageSettings(this);
Expand All @@ -79,16 +133,17 @@ public override void LoadSettingsFromStorage()

public override void SaveSettingsToStorage()
{
// Synchronize backing properties with UI.
if (this._window != null)
{
this._window.SyncPageWithControlSettings(this);
}

// Save settings.
SaveBool(WaitOnNormalExitSetting, this.WaitOnNormalExit);
SaveBool(WaitOnAbnormalExitSetting, this.WaitOnAbnormalExit);
SaveBool(EditAndContinueSetting, this.EditAndContinue);
this._waitOnAbnormalExitModified = false;
this._waitOnNormalExitModified = false;
this._editAndContinueModified = false;
}
}
}
7 changes: 5 additions & 2 deletions Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ private void StartNodeProcess(string file, string nodePath, bool shouldStartBrow
psi.EnvironmentVariables[nameValue.Key] = nameValue.Value;
}

var generalOptions = NodejsPackage.Instance.GeneralOptionsPage;
generalOptions.RefreshSettingsFromStorage();

var process = NodeProcess.Start(
psi,
waitOnAbnormal: NodejsPackage.Instance.GeneralOptionsPage.WaitOnAbnormalExit,
waitOnNormal: NodejsPackage.Instance.GeneralOptionsPage.WaitOnNormalExit);
waitOnAbnormal: generalOptions.WaitOnAbnormalExit,
waitOnNormal: generalOptions.WaitOnNormalExit);

this._project.OnDispose += process.ResponseToTerminateEvent;

Expand Down
5 changes: 5 additions & 0 deletions Nodejs/Product/Nodejs/UnifiedSettings.pkgdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// CacheTag must change whenever the Unified Settings manifest changes.
[$RootKey$\SettingsManifests\{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}]
@="Microsoft.NodejsTools.NodejsPackage"
"ManifestPath"="$PackageFolder$\UnifiedSettings\NodejsGeneralOptions.registration.json"
"CacheTag"=qword:08DE50FA23033A60
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"$schema": "https://aka.ms/unified-settings-experience/registration/schema",
"properties": {
"debugging.nodejs.general.waitOnAbnormalExit": {
"type": "boolean",
"title": "@UnifiedSettings_WaitOnAbnormalExit;{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}",
"default": true,
"order": 0,
"migration": {
"custom": {
"mode": "full",
"inputs": [
{
"store": "VsUserSettingsRegistry",
"path": "NodejsTools\\Options\\General\\WaitOnAbnormalExit"
}
],
"map": [
{
"result": true,
"matches": [ "True" ]
},
{
"result": false,
"matches": [ "False" ]
}
]
}
}
},
"debugging.nodejs.general.waitOnNormalExit": {
"type": "boolean",
"title": "@UnifiedSettings_WaitOnNormalExit;{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}",
"default": false,
"order": 1,
"migration": {
"custom": {
"mode": "full",
"inputs": [
{
"store": "VsUserSettingsRegistry",
"path": "NodejsTools\\Options\\General\\WaitOnNormalExit"
}
],
"map": [
{
"result": true,
"matches": [ "True" ]
},
{
"result": false,
"matches": [ "False" ]
}
]
}
}
},
"debugging.nodejs.general.editAndContinue": {
"type": "boolean",
"title": "@UnifiedSettings_EditAndContinue;{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}",
"default": true,
"order": 2,
"migration": {
"custom": {
"mode": "full",
"inputs": [
{
"store": "VsUserSettingsRegistry",
"path": "NodejsTools\\Options\\General\\EditAndContinue"
}
],
"map": [
{
"result": true,
"matches": [ "True" ]
},
{
"result": false,
"matches": [ "False" ]
}
]
}
}
}
},
"categories": {
"debugging.nodejs": {
"title": "@UnifiedSettings_Nodejs;{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}"
},
"debugging.nodejs.general": {
"title": "@UnifiedSettings_General;{FE8A8C3D-328A-476D-99F9-2A24B75F8C7F}",
"legacyOptionPageId": "EF677A38-0953-39C2-A228-2FBE8F8F082E"
}
}
}
15 changes: 15 additions & 0 deletions Nodejs/Product/Nodejs/VSPackage.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@
<data name="115" xml:space="preserve">
<value>General</value>
</data>
<data name="UnifiedSettings_Nodejs" xml:space="preserve">
<value>Node.js</value>
</data>
<data name="UnifiedSettings_General" xml:space="preserve">
<value>General</value>
</data>
<data name="UnifiedSettings_WaitOnAbnormalExit" xml:space="preserve">
<value>Wait for input when process exits abnormally</value>
</data>
<data name="UnifiedSettings_WaitOnNormalExit" xml:space="preserve">
<value>Wait for input when process exits normally</value>
</data>
<data name="UnifiedSettings_EditAndContinue" xml:space="preserve">
<value>Enable Edit and Continue</value>
</data>
<data name="116" xml:space="preserve">
<value>Npm</value>
</data>
Expand Down
Loading