From 2b936d0dea40b1fbcb18683cd7a38b15d74fd31e Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Mon, 28 Jul 2025 15:28:57 +0300 Subject: [PATCH] [terminal] IJPL-178962 BackendTerminalHyperlinkHighlighter formatting Just some empty lines to split run(). Ideally we need to split it into several methods, but let's postpone it until the implementation is ready. GitOrigin-RevId: 37dc4d2c862870dad41b0a8058bf5fddfed25484 --- .../hyperlinks/BackendTerminalHyperlinkHighlighter.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/terminal/backend/src/com/intellij/terminal/backend/hyperlinks/BackendTerminalHyperlinkHighlighter.kt b/plugins/terminal/backend/src/com/intellij/terminal/backend/hyperlinks/BackendTerminalHyperlinkHighlighter.kt index 03282d4ee09d..5325a1030214 100644 --- a/plugins/terminal/backend/src/com/intellij/terminal/backend/hyperlinks/BackendTerminalHyperlinkHighlighter.kt +++ b/plugins/terminal/backend/src/com/intellij/terminal/backend/hyperlinks/BackendTerminalHyperlinkHighlighter.kt @@ -128,6 +128,7 @@ internal class BackendTerminalHyperlinkHighlighter( "startOffset=$startOffset, " + "trimmed=${outputModel.relativeOffset(0).toAbsolute()}" } + fun logEvent(event: TerminalHyperlinksChangedEvent) { if (!LOG.isDebugEnabled) return count += event.hyperlinks.size @@ -142,6 +143,7 @@ internal class BackendTerminalHyperlinkHighlighter( "${first?.absoluteStartOffset?.addRelative()}-${last?.absoluteEndOffset?.addRelative()} (IDs ${last?.id}-${first?.id})" ) } + suspend fun send(results: List, firstBatch: Boolean, lastBatch: Boolean) { require(!(firstBatch && lastBatch)) if (results.isNotEmpty() || firstBatch || lastBatch) { @@ -150,12 +152,14 @@ internal class BackendTerminalHyperlinkHighlighter( logEvent(event) } } + val lineCount = document.lineCount if (lineCount == 0) { send(emptyList(), firstBatch = true, lastBatch = false) send(emptyList(), firstBatch = false, lastBatch = true) return } + val startLineInclusive = document.getLineNumber(startOffset.toRelative()) val endLineInclusive = lineCount - 1 // Process in the reverse direction to highlight the visible part first. @@ -168,6 +172,7 @@ internal class BackendTerminalHyperlinkHighlighter( send(batch, firstBatch = endBatchInclusive == endLineInclusive, lastBatch = false) endBatchInclusive = startBatchInclusive - 1 } + send(emptyList(), firstBatch = false, lastBatch = true) val lastID = hyperlinkId.get() LOG.debug {