From f7a19a3750b36d4c51807a8b7a3020a3ff54d88b Mon Sep 17 00:00:00 2001 From: Kirill Starkov Date: Fri, 20 Dec 2024 23:39:22 +0800 Subject: [PATCH] fix completion filepath --- refact_lsp | 2 +- .../refactai/codecompletion/RefactAICompletionProvider.kt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/refact_lsp b/refact_lsp index 312e7df8..88d050b1 100644 --- a/refact_lsp +++ b/refact_lsp @@ -1 +1 @@ -self_configure \ No newline at end of file +main \ No newline at end of file diff --git a/src/main/kotlin/com/smallcloud/refactai/codecompletion/RefactAICompletionProvider.kt b/src/main/kotlin/com/smallcloud/refactai/codecompletion/RefactAICompletionProvider.kt index ae5e3605..6117b8c5 100644 --- a/src/main/kotlin/com/smallcloud/refactai/codecompletion/RefactAICompletionProvider.kt +++ b/src/main/kotlin/com/smallcloud/refactai/codecompletion/RefactAICompletionProvider.kt @@ -148,17 +148,16 @@ class RefactAICompletionProvider : DebouncedInlineCompletionProvider() { override fun restartOn(event: InlineCompletionEvent): Boolean = false - private fun getActiveFile(document: Document, project: Project?): String? { - val projectPath = project?.basePath ?: return null + private fun getActiveFile(document: Document): String? { val file = FileDocumentManager.getInstance().getFile(document) ?: return null - return Path(file.path).toUri().toString().replace(Path(projectPath).toUri().toString(), "") + return Path(file.path).toString() } private class Context(val request: SMCRequest, val editorState: EditorTextState, val force: Boolean = false) private fun makeContext(request: InlineCompletionRequest): Context? { - val fileName = getActiveFile(request.document, request.editor.project) ?: return null + val fileName = getActiveFile(request.document) ?: return null if (PrivacyService.instance.getPrivacy(FileDocumentManager.getInstance().getFile(request.document)) == Privacy.DISABLED && !InferenceGlobalContext.isSelfHosted ) return null