You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our formatting engine constantly switches between TextChange and TextEdit, and generally uses arrays for things, because it was written with LSP concepts (TextEdit and arrays) in mind. We should consider re-writing it to use more modern concepts/features.
The text was updated successfully, but these errors were encountered:
…dit` (#10855)
Fixes#10842
The formatting self-nerd-sniping continues.
The formatting engine was written to use the LSP `TextEdit` class, which
makes some sense, but also uses Roslyn APIs like `SourceText` a lot,
which uses the `TextChange` struct instead. This meant lots of code to
convert to and from the two types. Changing the whole formatting engine
over to `TextChange`, and using more `TextSpan`, `LinePositionSpan` etc.
removes a lot of this code. It also makes a lot more sense in cohosting,
to boot.
I wouldn't claim that I've gone through and improved the perf of the
formatting engine, but rather I've use the changes to lead me to things
that need fixing. ie, I started out moving from `TextEdit[]` to
`ImmutableArray<TextChange>`, and this let me to places where pooled
array builders could be used, and places where `Range` and `Position`
were used which didn't make much sense, and then the constructor for
`LinePosition` threw at one point because it turns out we were only
using the `Line` property from the `Position` that used to be used, and
so never validated the characters, so that API moved to `int`, etc.
TL;DR the commits tell the story, and there could well be something I
missed, if it never came across my plate for another reason.
Our formatting engine constantly switches between
TextChange
andTextEdit
, and generally uses arrays for things, because it was written with LSP concepts (TextEdit and arrays) in mind. We should consider re-writing it to use more modern concepts/features.The text was updated successfully, but these errors were encountered: