Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeWhisperer has issues with Chinese comments #3607

Closed
AnonymMa opened this issue Apr 18, 2023 · 22 comments
Closed

CodeWhisperer has issues with Chinese comments #3607

AnonymMa opened this issue Apr 18, 2023 · 22 comments
Labels
bug We can reproduce the issue and confirmed it is a bug. codewhisperer

Comments

@AnonymMa
Copy link

注释的中文显示是乱码


Toolkit: AWS Toolkit For JetBrains 1.65-223
OS: Windows 10 10.0
IDE: IntelliJ IDEA Ultimate Edition 223

@rli rli changed the title 注释的中文显示是乱码 Chinese localization is poor Apr 18, 2023
@rli
Copy link
Contributor

rli commented Apr 18, 2023

Could you provide an example?

@rli rli added the feature-request New feature or enhancement. May require GitHub community feedback. label Apr 18, 2023
@yangqiaosvip
Copy link

image

@rli rli added codewhisperer bug We can reproduce the issue and confirmed it is a bug. and removed feature-request New feature or enhancement. May require GitHub community feedback. labels May 2, 2023
@rli rli changed the title Chinese localization is poor CodeWhisperer has issues with Chinese comments May 2, 2023
@backtracker
Copy link

When will this problem be fixed?

@hengxingstu
Copy link

we need Chinese!!!And also need CodeWhisperer can write comment in Chinese!

@fe19880924
Copy link

When will this problem be fixed? we need Chinese!

@nwgdk
Copy link

nwgdk commented Jul 15, 2023

Any progress? I've encountered the same issue, it seems that it doesn't support Chinese display.

@fanheyan
Copy link

Toolkit: AWS Toolkit For JetBrains 1.65-223
OS: Windows 10 10.0
IDE: IntelliJ IDEA Ultimate Edition 223

When will this problem be fixed?

@backtracker
Copy link

一个乱码问题四个月没处理好,简直离谱

@cheng470
Copy link

I have same problem. I accepted the code that CodeWhisperer generated and then delete the comment manually :(

@yufire
Copy link

yufire commented Aug 23, 2023

Why Chinese will display garbled characters。
At present, the code prompt shows a box, and the one inserted into the editor by pressing the Tab key is normal Chinese

@JackieLeee
Copy link

the same problem
image

@looplouis
Copy link

Obviously, they've given up.

@rli rli pinned this issue Sep 1, 2023
@duanluan
Copy link

duanluan commented Sep 6, 2023

Change the editor font, such as Microsoft YaHei Mono.

@nwgdk
Copy link

nwgdk commented Sep 6, 2023

Change the editor font, such as Microsoft YaHei Mono.

更改这个字体有用吗?

@duanluan
Copy link

duanluan commented Sep 8, 2023

更改这个字体有用吗?

当然有用……不然我发出来干嘛

@Zakariyya
Copy link

更改这个字体有用吗?

当然有用……不然我发出来干嘛

我试了没用,不过还是谢谢你

@Zakariyya
Copy link

I have same problem

@ican2056
Copy link

ican2056 commented Sep 8, 2023

@nwgdk @Zakariyya
instrumented-aws-toolkit-jetbrains-IU-1.77-232.jar中的CodeWhispererInlayRenderer.class替换下就中文正常不乱码了,替换的文件见附件CodeWhispererInlayRenderer.zip,修改后的源码如下:

// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.services.codewhisperer.inlay

import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorCustomElementRenderer
import com.intellij.openapi.editor.colors.impl.FontPreferencesImpl
import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry
import com.intellij.openapi.editor.impl.FontInfo
import com.intellij.xdebugger.ui.DebuggerColors
import java.awt.Font
import java.awt.Graphics

abstract class CodeWhispererInlayRenderer(protected val myValue: String) : EditorCustomElementRenderer {
    fun getFontInfo(editor: Editor): FontInfo {
        val colorsScheme = editor.colorsScheme
        val fontPreferences = colorsScheme.fontPreferences
        val attributes = editor.colorsScheme.getAttributes(DebuggerColors.INLINED_VALUES_EXECUTION_LINE)
        val fontStyle = attributes?.fontType ?: Font.PLAIN

        val yaHeiFontPreferences = FontPreferencesImpl()
        fontPreferences.copyTo(yaHeiFontPreferences)
        yaHeiFontPreferences.realFontFamilies.clear();
        yaHeiFontPreferences.realFontFamilies.add("Microsoft Yahei")
        yaHeiFontPreferences.effectiveFontFamilies.clear()
        yaHeiFontPreferences.effectiveFontFamilies.add("Microsoft Yahei")
        yaHeiFontPreferences.setFontSize("Microsoft Yahei",13)

        return ComplementaryFontsRegistry.getFontAbleToDisplay(
            'a'.toInt(),
            Font.PLAIN,
            yaHeiFontPreferences,
            FontInfo.getFontRenderContext(editor.contentComponent)
        )
    }

    fun applyCodeWhispererColorAndFontSettings(editor: Editor, g: Graphics) {
        val attributes = editor.colorsScheme.getAttributes(DebuggerColors.INLINED_VALUES_EXECUTION_LINE) ?: return
        val fgColor = attributes.foregroundColor ?: return
        g.color = fgColor
        val fontInfo = getFontInfo(editor)
        g.font = fontInfo.font
    }
}

CodeWhispererInlayRenderer.zip

@haitachi
Copy link

同じ問題に遭遇する
どうやって解決すればいいですか。

@duanluan
Copy link

我试了没用,不过还是谢谢你

我 IDEA 和 PyCharm 改了都有用,Codeium 也是同样的问题,我也是这样解决的。

@AnonymMa
Copy link
Author

确实. 进入[ 设置 ] ->[ 编辑器 ] ->[ 字体 ], 将字体修改位[ Microsoft YaHei UI ], 则没有乱码的问题了.

@kkccboy
Copy link

kkccboy commented Sep 21, 2023

确实. 进入[ 设置 ] ->[ 编辑器 ] ->[ 字体 ], 将字体修改位[ Microsoft YaHei UI ], 则没有乱码的问题了.

谢谢,这个方法的确有用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We can reproduce the issue and confirmed it is a bug. codewhisperer
Projects
None yet
Development

No branches or pull requests