File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
packages/language-server/src/plugins/typescript/features Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider {
4646 . map ( ( diagnostic ) => mapObjWithRangeToOriginal ( fragment , diagnostic ) )
4747 . filter ( hasNoNegativeLines )
4848 . filter ( isNoFalsePositive ( document . getText ( ) , tsDoc ) )
49- . map ( enhanceIfNecessary ) ;
49+ . map ( enhanceIfNecessary )
50+ . map ( swapRangeStartEndIfNecessary ) ;
5051 }
5152
5253 private getDiagnosticTag ( diagnostic : ts . Diagnostic ) {
@@ -138,3 +139,19 @@ function enhanceIfNecessary(diagnostic: Diagnostic): Diagnostic {
138139
139140 return diagnostic ;
140141}
142+
143+ /**
144+ * Due to source mapping, some ranges may be swapped: Start is end. Swap back in this case.
145+ */
146+ function swapRangeStartEndIfNecessary ( diag : Diagnostic ) : Diagnostic {
147+ if (
148+ diag . range . end . line < diag . range . start . line ||
149+ ( diag . range . end . line === diag . range . start . line &&
150+ diag . range . end . character < diag . range . start . character )
151+ ) {
152+ const start = diag . range . start ;
153+ diag . range . start = diag . range . end ;
154+ diag . range . end = start ;
155+ }
156+ return diag ;
157+ }
You can’t perform that action at this time.
0 commit comments