Exafunction / CodeiumJetBrains

Codeium JetBrains Plugin
MIT License
41 stars 13 forks source link

Non-Ascii unicode characters garbled in suggestion #1

Open fortenforge opened 6 months ago

fortenforge commented 6 months ago

This problem only seems to happen on some versions of JetBrains on Windows.

reproduce

romanstingler commented 5 months ago

I think here someone of the codeium guys must giva a helping hand. @pqn when entering single chinese/japanese characters

 var arr = [말, ]; 

I get a completion (EditorManager.kt -> applyCompletionFeedback)

 completion_id: "e34be170-0bc0-4722-a25c-f557020959d4"
text: "      var arr = [\353\247\220, \353\260\224];"
stop: "\n"
score: -2.779088921855237
tokens: 39277
tokens: 242
tokens: 947
decoded_tokens: "<INVALID_UTF8>"
decoded_tokens: "<INVALID_UTF8>"
decoded_tokens: "];\n"
probabilities: 0.08463465422391891
probabilities: 0.23204736411571503
probabilities: 0.09497058391571045
adjusted_probabilities: 0.13103549182415009
adjusted_probabilities: 0.5395587086677551
adjusted_probabilities: 0.07481787353754044
generated_length: 3
12: 2
14: "\353\260\224];\n"

but when I have something like that

      var arr = [말씀, 말씀, 말씀, 말씀, ]

It doesn't generate any completions but throws a grpc error

java.lang.Throwable: Process creation:
    at com.intellij.execution.process.BaseOSProcessHandler.<init>(BaseOSProcessHandler.java:32)
    at com.intellij.execution.process.OSProcessHandler.<init>(OSProcessHandler.java:44)
    at com.intellij.execution.process.KillableProcessHandler.<init>(KillableProcessHandler.java:41)
    at com.codeium.intellij.language_server.LanguageServerProcessHandler.<init>(LanguageServerProcessHandler.kt:17)
    at com.codeium.intellij.language_server.LanguageServerLauncherActivity$runActivity$1.invokeSuspend(LanguageServerLauncherActivity.kt:306)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
fortenforge commented 5 months ago

that's not a GRPC error, and that error is benign. it's just complaining that the process hasn't written out data in a while.

AoEiuV020 commented 4 weeks ago

Some fonts, like the built-in DialogInput or the downloaded 'Microsoft YaHei Mono,' display correctly, but they all look unattractive.

arnesacnussem commented 6 days ago

This is a simple fix by add a fallback font maybe the FontMetrics part also need to be changed, but this is just good enough for me demo

git patch ``` Subject: [PATCH] simple fix for #1 --- Index: src/main/kotlin/com/codeium/intellij/CompletionInlayRenderer.kt IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/kotlin/com/codeium/intellij/CompletionInlayRenderer.kt b/src/main/kotlin/com/codeium/intellij/CompletionInlayRenderer.kt --- a/src/main/kotlin/com/codeium/intellij/CompletionInlayRenderer.kt (revision 277b388cacff14f29ea10681c214b4002fe63fa3) +++ b/src/main/kotlin/com/codeium/intellij/CompletionInlayRenderer.kt (revision 789dfb12f77c07c0b3a3aa973da786b09080c1d5) @@ -7,9 +7,11 @@ import com.intellij.openapi.editor.EditorCustomElementRenderer import com.intellij.openapi.editor.Inlay import com.intellij.openapi.editor.colors.EditorFontType +import com.intellij.openapi.editor.ex.util.EditorUtil import com.intellij.openapi.editor.markup.TextAttributes import com.intellij.ui.JBColor import com.intellij.util.ui.GraphicsUtil +import com.intellij.util.ui.UIUtil.getFontWithFallback import java.awt.Font import java.awt.Graphics import java.awt.Graphics2D @@ -63,7 +65,8 @@ inlay.editor.contentComponent.getFontMetrics( inlay.editor.colorsScheme.getFont(EditorFontType.PLAIN)) val lineHeight = inlay.editor.lineHeight.toDouble() - val font: Font = inlay.editor.colorsScheme.getFont(EditorFontType.PLAIN) + val editorFont: Font = EditorUtil.getEditorFont() + val font = getFontWithFallback(editorFont.family, editorFont.style, editorFont.size) val fontBaseline = ceil(font.createGlyphVector(fontMetrics.fontRenderContext, "A").visualBounds.height) val linePadding = (lineHeight - fontBaseline) / 2.0 ```

compiled class file CompletionInlayRenderer.zip

ref: HintRenderer example