Skip to content

Commit

Permalink
Merge pull request #10196 from microsoft/seanmcm/cherrypick_1_13_5
Browse files Browse the repository at this point in the history
Cherry-picks for 1.13.5
  • Loading branch information
sean-mcmanus authored Nov 28, 2022
2 parents c549c07 + 24f5fdd commit 7fec8ba
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 13 deletions.
12 changes: 12 additions & 0 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# C/C++ for Visual Studio Code Changelog

## Version 1.13.5: November 28, 2022
### Bug Fixes
* Fix "Step Over past a logpoint stops at the wrong place". [#9995](https://github.com/microsoft/vscode-cpptools/issues/9995)
* Fix "Don't hardcode path to kill in UnixUtilities". [#10124](https://github.com/microsoft/vscode-cpptools/issues/10124)
* Ellie Hermaszewska (@expipiplus1) [PR #1373](https://github.com/microsoft/MIEngine/pull/1373)
* Fix the create declaration/definition feature not adding the definition if a new source file needs to be created. [#10159](https://github.com/microsoft/vscode-cpptools/issues/10159)
* Fix the create declaration/definition feature not having the correct cursor location after adding a definition. [#10160](https://github.com/microsoft/vscode-cpptools/issues/10160)
* Fix the create declaration/definition feature not formatting inserted definitions. [#10161](https://github.com/microsoft/vscode-cpptools/issues/10161)
* This has the side-effect of fixing the extra newlines created in a new file if clang-format is used. [#10164](https://github.com/microsoft/vscode-cpptools/issues/10164)
* However, clang-format 15 has a bug which can cause formatting of newly inserted definitions to fail in some cases: [LLVM#59178](https://github.com/llvm/llvm-project/issues/59178)
* Fix formatting when clang-format 11 or earlier is used (and another issue for version 8 or earlier). [#10178](https://github.com/microsoft/vscode-cpptools/issues/10178)

## Version 1.13.4: November 17, 2022
### New Features
* Add the ability to generate definitions from declarations and vice versa. [#664](https://github.com/microsoft/vscode-cpptools/issues/664)
Expand Down
110 changes: 102 additions & 8 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cpptools",
"displayName": "C/C++",
"description": "C/C++ IntelliSense, debugging, and code browsing.",
"version": "1.13.4-main",
"version": "1.13.5-main",
"publisher": "ms-vscode",
"icon": "LanguageCCPP_color_128x.png",
"readme": "README.md",
Expand Down Expand Up @@ -286,7 +286,7 @@
"name": "iar",
"source": "iar",
"owner": "cpptools",
"fileLocation" : "absolute",
"fileLocation": "absolute",
"pattern": {
"regexp": "^\"(.*?)\",(\\d+)\\s+(?:[Ff]atal\\s+)?([Ww]arning|[Ee]rror)\\[(\\w+\\d+)\\]:\\s+(.*)$",
"file": 1,
Expand Down Expand Up @@ -3453,9 +3453,30 @@
"default": true
},
"engineLogging": {
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
},
"trace": {
"type": "boolean",
Expand All @@ -3466,6 +3487,32 @@
"type": "boolean",
"description": "%c_cpp.debuggers.logging.traceResponse.description%",
"default": false
},
"natvisDiagnostics": {
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.natvisDiagnostics.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
}
}
},
Expand Down Expand Up @@ -4194,9 +4241,30 @@
"default": true
},
"engineLogging": {
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
},
"trace": {
"type": "boolean",
Expand All @@ -4207,6 +4275,32 @@
"type": "boolean",
"description": "%c_cpp.debuggers.logging.traceResponse.description%",
"default": false
},
"natvisDiagnostics": {
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.natvisDiagnostics.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,10 @@
"c_cpp.semanticTokenTypes.numberLiteral.description": "Style for C++ user-defined literal numbers.",
"c_cpp.semanticTokenTypes.stringLiteral.description": "Style for C++ user-defined literal strings.",
"c_cpp.semanticTokenModifiers.global.description": "Style to use for symbols that are global.",
"c_cpp.semanticTokenModifiers.local.description": "Style to use for symbols that are local."
"c_cpp.semanticTokenModifiers.local.description": "Style to use for symbols that are local.",
"c_cpp.debuggers.logging.natvisDiagnostics.description": "Optional flag to determine whether diagnostic natvis messages should be logged to the Debug Console. Defaults to None.",
"c_cpp.debuggers.logging.category.verbose.description": "Logs that are used for interactive investigation during development. These logs should primarily contain information useful for debugging and have no long-term value.",
"c_cpp.debuggers.logging.category.warning.description": "Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop.",
"c_cpp.debuggers.logging.category.error.description": "Logs that highlight when the current flow of execution is stopped due to a failure. These should indicate a failure in the current activity, not an application-wide failure.",
"c_cpp.debuggers.logging.category.none.description": "Not used for writing log messages. Specifies that a logging category should not write any messages."
}
38 changes: 37 additions & 1 deletion Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3000,11 +3000,15 @@ export class DefaultClient implements Client {
const workspaceEdit: vscode.WorkspaceEdit = new vscode.WorkspaceEdit();
let modifiedDocument: vscode.Uri | undefined;
let lastEdit: vscode.TextEdit | undefined;
let numNewlinesFromPreviousEdits: number = 0;
for (const file in result.changes) {
const uri: vscode.Uri = vscode.Uri.file(file);
const edits: vscode.TextEdit[] = [];
for (const edit of result.changes[file]) {
const range: vscode.Range = makeVscodeRange(edit.range);
if (lastEdit && lastEdit.range.isEqual(range)) {
numNewlinesFromPreviousEdits += (lastEdit.newText.match(/\n/g) || []).length;
}
lastEdit = new vscode.TextEdit(range, edit.newText);
edits.push(lastEdit);
}
Expand All @@ -3013,8 +3017,40 @@ export class DefaultClient implements Client {
};
if (modifiedDocument && lastEdit) {
await vscode.workspace.applyEdit(workspaceEdit);
const selectionRange: vscode.Range = lastEdit.range; // TODO: range should be the new range after text edit was applied.
let numNewlines: number = (lastEdit.newText.match(/\n/g) || []).length;

// Move the cursor to the new code, accounting for \n or \n\n at the start.
let startLine: number = lastEdit.range.start.line;
if (lastEdit.newText.startsWith("\r\n\r\n") || lastEdit.newText.startsWith("\n\n")) {
startLine += 2;
numNewlines -= 2;
} else if (lastEdit.newText.startsWith("\r\n") || lastEdit.newText.startsWith("\n")) {
startLine += 1;
numNewlines -= 1;
}
if (!lastEdit.newText.endsWith("\n")) {
numNewlines++; // Increase the format range.
}

const selectionPosition: vscode.Position = new vscode.Position(startLine + numNewlinesFromPreviousEdits, 0);
const selectionRange: vscode.Range = new vscode.Range(selectionPosition, selectionPosition);
await vscode.window.showTextDocument(modifiedDocument, { selection: selectionRange });

// Run formatRange.
const formatEdits: vscode.WorkspaceEdit = new vscode.WorkspaceEdit();
const formatRange: vscode.Range = new vscode.Range(selectionRange.start, new vscode.Position(selectionRange.start.line + numNewlines, 0));
const settings: OtherSettings = new OtherSettings(vscode.workspace.getWorkspaceFolder(modifiedDocument)?.uri);
const formatOptions: vscode.FormattingOptions = {
insertSpaces: settings.editorInsertSpaces ?? true,
tabSize: settings.editorTabSize ?? 4
};
const formatTextEdits: vscode.TextEdit[] | undefined = await vscode.commands.executeCommand<vscode.TextEdit[] | undefined>("vscode.executeFormatRangeProvider", modifiedDocument, formatRange, formatOptions);
if (formatTextEdits && formatTextEdits.length > 0) {
formatEdits.set(modifiedDocument, formatTextEdits);
}
if (formatEdits.size > 0) {
await vscode.workspace.applyEdit(formatEdits);
}
}
}
}
Expand Down
53 changes: 50 additions & 3 deletions Extension/tools/OptionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,30 @@
"default": true
},
"engineLogging": {
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
},
"trace": {
"type": "boolean",
Expand All @@ -89,6 +110,32 @@
"type": "boolean",
"description": "%c_cpp.debuggers.logging.traceResponse.description%",
"default": false
},
"natvisDiagnostics": {
"anyOf": [
{
"type": "string",
"enum": [
"verbose",
"warning",
"error",
"none"
],
"enumDescriptions": [
"%c_cpp.debuggers.logging.category.verbose.description%",
"%c_cpp.debuggers.logging.category.warning.description%",
"%c_cpp.debuggers.logging.category.error.description%",
"%c_cpp.debuggers.logging.category.none.description%"
],
"description": "%c_cpp.debuggers.logging.natvisDiagnostics.description%",
"default": "none"
},
{
"type": "boolean",
"description": "%c_cpp.debuggers.logging.engineLogging.description%",
"default": false
}
]
}
}
},
Expand Down

0 comments on commit 7fec8ba

Please sign in to comment.