From 12b71b689866e45b1f58492eba549ed4683b73d3 Mon Sep 17 00:00:00 2001 From: Rik Nauta Date: Fri, 9 Aug 2024 12:30:16 +0200 Subject: [PATCH] Potential Fix 1 --- .../sourcegraph/cody/agent/protocol/ProtocolTextDocument.kt | 1 + .../com/sourcegraph/cody/inspections/CodyFixHighlightPass.kt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/sourcegraph/cody/agent/protocol/ProtocolTextDocument.kt b/src/main/kotlin/com/sourcegraph/cody/agent/protocol/ProtocolTextDocument.kt index 9c66706fda..7ca3a22818 100644 --- a/src/main/kotlin/com/sourcegraph/cody/agent/protocol/ProtocolTextDocument.kt +++ b/src/main/kotlin/com/sourcegraph/cody/agent/protocol/ProtocolTextDocument.kt @@ -198,6 +198,7 @@ private constructor( return normalizeUriOrPath(uriString) } + //TODO: CODY-3223 - This should be moved to the protocol extension layer so that ALL uri's & paths are properly converted. Probably also means we want to alter the generated bindings to provide a hook or automatically generate the serializer. @JvmStatic fun normalizeUriOrPath(uriString: String): String { val hasScheme = uriString.startsWith("file://") diff --git a/src/main/kotlin/com/sourcegraph/cody/inspections/CodyFixHighlightPass.kt b/src/main/kotlin/com/sourcegraph/cody/inspections/CodyFixHighlightPass.kt index 270111f082..2d35f93a37 100644 --- a/src/main/kotlin/com/sourcegraph/cody/inspections/CodyFixHighlightPass.kt +++ b/src/main/kotlin/com/sourcegraph/cody/inspections/CodyFixHighlightPass.kt @@ -88,7 +88,7 @@ class CodyFixHighlightPass(val file: PsiFile, val editor: Editor) : location = // TODO: Rik Nauta -- Got incorrect range; see QA report Aug 6 2024. ProtocolLocation( - uri = protocolTextDocument.uri, + uri = ProtocolTextDocument.normalizeUriOrPath(protocolTextDocument.uri), range = document.codyRange(it.startOffset, it.endOffset)), code = it.problemGroup?.problemName) } catch (x: Exception) { @@ -113,7 +113,7 @@ class CodyFixHighlightPass(val file: PsiFile, val editor: Editor) : } val location = ProtocolLocation( - uri = protocolTextDocument.uri, + uri = ProtocolTextDocument.normalizeUriOrPath(protocolTextDocument.uri), range = document.codyRange(highlight.startOffset, highlight.endOffset)) val provideResponse = agent.server