From 2857bb9703ca5abf3c845fc9e56c60e63fb97448 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 5 Jul 2017 12:47:32 -0700 Subject: [PATCH] remove `fixCaretPosition` --- src/harness/fourslash.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 4cc5f7abd6f..122bff1a4a0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1652,7 +1652,6 @@ namespace FourSlash { } } - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1678,7 +1677,6 @@ namespace FourSlash { // Don't need to examine formatting because there are no formatting changes on backspace. } - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1722,7 +1720,6 @@ namespace FourSlash { } } - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1741,7 +1738,6 @@ namespace FourSlash { } } - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1769,17 +1765,6 @@ namespace FourSlash { Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); } - private fixCaretPosition() { - // The caret can potentially end up between the \r and \n, which is confusing. If - // that happens, move it back one character - if (this.currentCaretPosition > 0) { - const ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); - if (ch === "\r") { - this.currentCaretPosition--; - } - } - } - /** * @returns The number of characters added to the file as a result of the edits. * May be negative. @@ -1836,19 +1821,16 @@ namespace FourSlash { public formatDocument() { const edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeSettings); this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - this.fixCaretPosition(); } public formatSelection(start: number, end: number) { const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeSettings); this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - this.fixCaretPosition(); } public formatOnType(pos: number, key: string) { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, pos, key, this.formatCodeSettings); this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - this.fixCaretPosition(); } private editScriptAndUpdateMarkers(fileName: string, editStart: number, editEnd: number, newText: string) {