Caret position in fourslash#16878
Conversation
| } | ||
|
|
||
| verifyIndentationAfterNewLine("1", 4); | ||
| // TODO (arozga): fix this. |
There was a problem hiding this comment.
No. This problem actually already existed, but is only exposed by adjusting the caret correctly. But actually fixing indenting behaviors is outside the scope of this PR. When this change gets accepted, I'll make a new issue for this.
| @@ -1740,31 +1722,25 @@ namespace FourSlash { | |||
| } | |||
There was a problem hiding this comment.
Do you know why above in if (this.enableFormatting) we update offset but not currentCaretPosition?
Also, is fixCaretPosition still necessary if we update it correctly?
There was a problem hiding this comment.
this.applyEdits returns the number of characters added/removed in the file, but this is different from the adjustment to the caret position (which is the number of characters added/removed in the file before the caret).
There was a problem hiding this comment.
fixCaretPosition appears to be unnecessary now.
| // of the incremental offset from each edit to the next. We assume these edit ranges don't overlap | ||
|
|
||
| edits = edits.sort((a, b) => a.span.start - b.span.start); | ||
| for (let i = 0; i < edits.length - 1; ++i) { |
| * @returns The number of characters added to the file as a result of the edits. | ||
| * May be negative. | ||
| */ | ||
| private applyEdits(fileName: string, edits: ts.TextChange[], isFormattingEdit = false): number { |
There was a problem hiding this comment.
The isFormattingEdit parameter is omitted only once; consider making it non-optional. Same for the parameters in printCurrentFileState.
Fixes #16877.