Skip to content

Commit 6022088

Browse files
committed
Fix issue where implement abstract members code action doesn't show up
if you don't mark the entire text. Happens in editors that are not VSCode
1 parent 6484b9b commit 6022088

File tree

1 file changed

+10
-2
lines changed
  • server/src/main/kotlin/org/javacs/kt/codeaction/quickfix

1 file changed

+10
-2
lines changed

server/src/main/kotlin/org/javacs/kt/codeaction/quickfix/QuickFix.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ interface QuickFix {
1616
}
1717

1818
fun diagnosticMatch(diagnostic: Diagnostic, range: Range, diagnosticTypes: Set<String>): Boolean =
19-
diagnostic.range.equals(range) && diagnosticTypes.contains(diagnostic.code.left)
19+
isDiagnosticInRange(diagnostic, range) && diagnosticTypes.contains(diagnostic.code.left)
20+
21+
// for a diagnostic to be in range the lines should be the same, and
22+
// the input character range should be within the bounds of the diagnostics range.
23+
private fun isDiagnosticInRange(diagnostic: Diagnostic, range: Range): Boolean {
24+
val diagnosticRange = diagnostic.range
25+
return diagnosticRange.start.line == range.start.line && diagnosticRange.end.line == range.end.line &&
26+
diagnosticRange.start.character <= range.start.character && diagnosticRange.end.character >= range.end.character
27+
}
2028

2129
fun diagnosticMatch(diagnostic: KotlinDiagnostic, startCursor: Int, endCursor: Int, diagnosticTypes: Set<String>): Boolean =
22-
diagnostic.textRanges.any { it.startOffset == startCursor && it.endOffset == endCursor } && diagnosticTypes.contains(diagnostic.factory.name)
30+
diagnostic.textRanges.any { it.startOffset <= startCursor && it.endOffset >= endCursor } && diagnosticTypes.contains(diagnostic.factory.name)
2331

2432
fun findDiagnosticMatch(diagnostics: List<Diagnostic>, range: Range, diagnosticTypes: Set<String>) =
2533
diagnostics.find { diagnosticMatch(it, range, diagnosticTypes) }

0 commit comments

Comments
 (0)