Skip to content

Commit d6e35c7

Browse files
Copilotntotten
andcommitted
Address code review feedback
- Fix countTrailingNewlines to use continue instead of break for \r - Clarify condition in forceFormatDocument to check > 1 instead of !== 1 Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
1 parent cef25d8 commit d6e35c7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/PrettierEditService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default class PrettierEditService implements Disposable {
204204
this.loggingService.logInfo("Document is already formatted.");
205205
return;
206206
}
207-
if (edits.length !== 1) {
207+
if (edits.length > 1) {
208208
this.loggingService.logWarning(`Expected 1 edit, got ${edits.length}`);
209209
return;
210210
}

src/test/suite/format.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe("Test format Document", () => {
6363
let count = 0;
6464
for (let i = str.length - 1; i >= 0; i--) {
6565
if (str[i] === '\n') count++;
66-
else if (str[i] !== '\r') break;
66+
else if (str[i] === '\r') continue; // Skip \r in CRLF
67+
else break;
6768
}
6869
return count;
6970
};

0 commit comments

Comments
 (0)