Skip to content

Commit d58688b

Browse files
authored
Invalidate range highlighters when the text is added. (#3205)
1 parent ad443cc commit d58688b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/editor/CodeWhispererEditorUtil.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,11 @@ object CodeWhispererEditorUtil {
9797
/**
9898
* Checks if the [otherRange] overlaps this TextRange. Note that the comparison is `<` because the endOffset of TextRange is exclusive.
9999
*/
100-
fun TextRange.overlaps(otherRange: TextRange) = max(startOffset, otherRange.startOffset) < min(endOffset, otherRange.endOffset)
100+
fun TextRange.overlaps(otherRange: TextRange): Boolean =
101+
if (otherRange.isEmpty) {
102+
// Handle case when otherRange is empty and within the range
103+
otherRange.startOffset in startOffset until endOffset
104+
} else {
105+
max(startOffset, otherRange.startOffset) < min(endOffset, otherRange.endOffset)
106+
}
101107
}

0 commit comments

Comments
 (0)