Skip to content

Commit 2857bb9

Browse files
committed
remove fixCaretPosition
1 parent b5e0698 commit 2857bb9

1 file changed

Lines changed: 0 additions & 18 deletions

File tree

src/harness/fourslash.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,6 @@ namespace FourSlash {
16521652
}
16531653
}
16541654

1655-
this.fixCaretPosition();
16561655
this.checkPostEditInvariants();
16571656
}
16581657

@@ -1678,7 +1677,6 @@ namespace FourSlash {
16781677
// Don't need to examine formatting because there are no formatting changes on backspace.
16791678
}
16801679

1681-
this.fixCaretPosition();
16821680
this.checkPostEditInvariants();
16831681
}
16841682

@@ -1722,7 +1720,6 @@ namespace FourSlash {
17221720
}
17231721
}
17241722

1725-
this.fixCaretPosition();
17261723
this.checkPostEditInvariants();
17271724
}
17281725

@@ -1741,7 +1738,6 @@ namespace FourSlash {
17411738
}
17421739
}
17431740

1744-
this.fixCaretPosition();
17451741

17461742
this.checkPostEditInvariants();
17471743
}
@@ -1769,17 +1765,6 @@ namespace FourSlash {
17691765
Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile);
17701766
}
17711767

1772-
private fixCaretPosition() {
1773-
// The caret can potentially end up between the \r and \n, which is confusing. If
1774-
// that happens, move it back one character
1775-
if (this.currentCaretPosition > 0) {
1776-
const ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition);
1777-
if (ch === "\r") {
1778-
this.currentCaretPosition--;
1779-
}
1780-
}
1781-
}
1782-
17831768
/**
17841769
* @returns The number of characters added to the file as a result of the edits.
17851770
* May be negative.
@@ -1836,19 +1821,16 @@ namespace FourSlash {
18361821
public formatDocument() {
18371822
const edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeSettings);
18381823
this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true);
1839-
this.fixCaretPosition();
18401824
}
18411825

18421826
public formatSelection(start: number, end: number) {
18431827
const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeSettings);
18441828
this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true);
1845-
this.fixCaretPosition();
18461829
}
18471830

18481831
public formatOnType(pos: number, key: string) {
18491832
const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, pos, key, this.formatCodeSettings);
18501833
this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true);
1851-
this.fixCaretPosition();
18521834
}
18531835

18541836
private editScriptAndUpdateMarkers(fileName: string, editStart: number, editEnd: number, newText: string) {

0 commit comments

Comments
 (0)