Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Commit 46f9b2d

Browse filesBrowse files
CryZeKalitaAlexey
authored andcommitted
Fix not working rustfmt on Windows (#311)
1 parent 681b66c commit 46f9b2d
Copy full SHA for 46f9b2d

File tree

1 file changed

+7
-4
lines changed
Filter options

1 file changed

+7
-4
lines changed

‎src/components/formatting/formatting_manager.ts

Copy file name to clipboardExpand all lines: src/components/formatting/formatting_manager.ts
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ export class FormattingManager implements DocumentFormattingEditProvider, Docume
168168
private parseDiffNewFormat(fileToProcess: Uri, diff: string): RustFmtDiff[] {
169169
const patches: RustFmtDiff[] = [];
170170
let currentPatch: RustFmtDiff | undefined = undefined;
171-
let currentFile: Uri | undefined = undefined;
171+
let currentFilePath: string | undefined = undefined;
172+
const fileToProcessPath = Uri.file(fileToProcess.path + '.fmt').fsPath;
172173

173174
for (const line of diff.split(/\n/)) {
174175
if (line.startsWith('Diff in')) {
@@ -188,7 +189,9 @@ export class FormattingManager implements DocumentFormattingEditProvider, Docume
188189
patches.push(currentPatch);
189190
}
190191

191-
currentFile = Uri.file(matches[1]);
192+
// The .path uncanonicalizes the path, which then gets turned into a Uri.
193+
// The .fsPath on both the current file and file to process fix the remaining differences.
194+
currentFilePath = Uri.file(Uri.file(matches[1]).path).fsPath;
192195
currentPatch = {
193196
startLine: parseInt(matches[2], 10),
194197
newLines: [],
@@ -198,11 +201,11 @@ export class FormattingManager implements DocumentFormattingEditProvider, Docume
198201

199202
// We haven't managed to figure out what file we're diffing yet, this shouldn't happen.
200203
// Probably a malformed diff.
201-
if (!currentFile) {
204+
if (!currentFilePath) {
202205
continue;
203206
}
204207

205-
if (currentFile.toString() !== fileToProcess.toString() + '.fmt') {
208+
if (currentFilePath !== fileToProcessPath) {
206209
continue;
207210
}
208211

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.