Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)

# 2.91.x
* Bump Roslyn to 5.0.0-2.25458.1 (PR: [#8593](https://github.com/dotnet/vscode-csharp/pull/8593))
* Bump Roslyn to 5.0.0-2.25458.10 (PR: [#8588](https://github.com/dotnet/vscode-csharp/pull/8588))
* Move brace adjustment on enter to on auto insert in LSP(PR: [#80075](https://github.com/dotnet/roslyn/pull/80075))
* Avoid throwing when obsolete overload of GetUpdatesAsync is invoked with empty array(PR: [#80161](https://github.com/dotnet/roslyn/pull/80161))
* Bump patch version of MSBuild packages(PR: [#80156](https://github.com/dotnet/roslyn/pull/80156))
* Include category in Hot Reload log messages(PR: [#80160](https://github.com/dotnet/roslyn/pull/80160))
* Store client's version for open docs (PR: [#80064](https://github.com/dotnet/roslyn/pull/80064))
* Pass global properties and the binary log path via RPC to BuildHost (PR: [#80094](https://github.com/dotnet/roslyn/pull/80094))
* Don't switch runtime / design time solutions if cohosting is on (PR: [#80065](https://github.com/dotnet/roslyn/pull/80065))
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"workspace"
],
"defaults": {
"roslyn": "5.0.0-2.25458.1",
"roslyn": "5.0.0-2.25458.10",
"omniSharp": "1.39.14",
"razor": "10.0.0-preview.25454.5",
"razorOmnisharp": "7.0.0-preview.23363.1",
Expand Down Expand Up @@ -128,7 +128,7 @@
"@types/semver": "7.3.13",
"@types/tmp": "0.0.33",
"@types/uuid": "^9.0.1",
"@types/vscode": "1.93.0",
"@types/vscode": "1.98.0",
"@types/yauzl": "2.10.0",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
Expand Down Expand Up @@ -688,7 +688,7 @@
}
],
"engines": {
"vscode": "^1.93.0"
"vscode": "^1.98.0"
},
"activationEvents": [
"onDebugInitialConfigurations",
Expand Down
33 changes: 27 additions & 6 deletions src/lsptoolshost/autoInsert/onAutoInsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import * as vscode from 'vscode';

import { FormattingOptions, LanguageClient, TextDocumentIdentifier } from 'vscode-languageclient/node';
import {
FormattingOptions,
InsertTextFormat,
LanguageClient,
TextDocumentIdentifier,
} from 'vscode-languageclient/node';
import * as RoslynProtocol from '../server/roslynProtocol';
import { RoslynLanguageServer } from '../server/roslynLanguageServer';

Expand Down Expand Up @@ -50,7 +55,13 @@ export function registerOnAutoInsert(languageServer: RoslynLanguageServer, langu
}

// Regular expression to match all whitespace characters except the newline character
const changeTrimmed = change.text.replace(/[^\S\n]+/g, '');
let changeTrimmed = change.text.replace(/[^\S\n]+/g, '');
// When hitting enter between braces, we can end up with two new lines added (one to move the cursor down to an empty line,
// and another to move the close brace to a new line below that). We still want to trigger on auto insert here, so remove
// duplicates before we check if the change matches a trigger character.
if (changeTrimmed.length > 1) {
changeTrimmed = [...new Set(changeTrimmed)].join('');
}

if (!vsTriggerCharacters.includes(changeTrimmed)) {
return;
Expand Down Expand Up @@ -98,12 +109,22 @@ async function applyAutoInsertEdit(
const textEdit = response._vs_textEdit;
const startPosition = new vscode.Position(textEdit.range.start.line, textEdit.range.start.character);
const endPosition = new vscode.Position(textEdit.range.end.line, textEdit.range.end.character);
const docComment = new vscode.SnippetString(textEdit.newText);
const code: any = vscode;
const textEdits = [new code.SnippetTextEdit(new vscode.Range(startPosition, endPosition), docComment)];

//const editor = vscode.window.activeTextEditor?.insertSnippet();

let textEdits: (vscode.TextEdit | vscode.SnippetTextEdit)[] = [];
if (response._vs_textEditFormat === InsertTextFormat.Snippet) {
const docComment = new vscode.SnippetString(textEdit.newText);
const edit = vscode.SnippetTextEdit.replace(new vscode.Range(startPosition, endPosition), docComment);
// Roslyn already formats the snippet correctly - we don't want the client to try and change the whitespace.
edit.keepWhitespace = true;
textEdits = [edit];
} else {
textEdits = [vscode.TextEdit.replace(new vscode.Range(startPosition, endPosition), textEdit.newText)];
}

const edit = new vscode.WorkspaceEdit();
edit.set(uri, textEdits);

const applied = vscode.workspace.applyEdit(edit);
if (!applied) {
throw new Error('Tried to apply an edit but an error occurred.');
Expand Down
Loading