From 0106f83fb9881bacd72e22bdce18239d8dddc6ee Mon Sep 17 00:00:00 2001 From: "Tyler Leonhardt (POWERSHELL)" Date: Wed, 6 May 2020 14:50:56 -0700 Subject: [PATCH 1/2] Fix startup on empty workspace and add useful snippets --- .vscode/snippets.code-snippets | 40 +++++++++++++++++++ .../Server/PsesLanguageServer.cs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .vscode/snippets.code-snippets diff --git a/.vscode/snippets.code-snippets b/.vscode/snippets.code-snippets new file mode 100644 index 000000000..bd69dc17a --- /dev/null +++ b/.vscode/snippets.code-snippets @@ -0,0 +1,40 @@ +{ + // Place your PowerShellEditorServices workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and + // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope + // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is + // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. + // Placeholders with the same ids are connected. + // Example: + // "Print to console": { + // "scope": "javascript,typescript", + // "prefix": "log", + // "body": [ + // "console.log('$1');", + // "$2" + // ], + // "description": "Log output to console" + // } + // Use https://snippet-generator.app/ to generate snippets + "Wait for debugger to be attached": { + "prefix": "WaitForDebugger", + "body": [ + "while (!System.Diagnostics.Debugger.IsAttached)", + "{", + " System.Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().Id);", + " System.Threading.Thread.Sleep(2000);", + "}" + ], + "description": "Wait for debugger to be attached" + }, + "Copyright header": { + "prefix": "CopyrightHeader", + "body": [ + "//", + "// Copyright (c) Microsoft. All rights reserved.", + "// Licensed under the MIT license. See LICENSE file in the project root for full license information.", + "//" + ], + "description": "Copyright header" + } +} diff --git a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs index c62973992..ff94ecad7 100644 --- a/src/PowerShellEditorServices/Server/PsesLanguageServer.cs +++ b/src/PowerShellEditorServices/Server/PsesLanguageServer.cs @@ -102,7 +102,7 @@ public async Task StartAsync() { workspaceService.WorkspacePath = request.RootUri.GetFileSystemPath(); } - else + else if (request.WorkspaceFolders != null) { // If RootUri isn't set, try to use the first WorkspaceFolder. // TODO: Support multi-workspace. From 98eb8a15177fb0d4763fdf2171b367ea8673722a Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Wed, 6 May 2020 15:03:33 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b81b2df8..4ee3ed934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## v2.2.0-preview.2 ### Wednesday, May 06, 2020 +- 🛫🐛 [PowerShellEditorServices #1289](https://github.com/PowerShell/PowerShellEditorServices/pull/1289) - + Fix startup on empty workspaces. - 🛫🐛 [PowerShellEditorServices #1285](https://github.com/PowerShell/PowerShellEditorServices/pull/1285) - Use API on ScriptBlock to generate PSCommand to run in ConstrainedLanguage mode. - ⚡️🧠 [PowerShellEditorServices #1283](https://github.com/PowerShell/PowerShellEditorServices/pull/1283) -