fix(editor): suppress ambiguous Unicode highlights in Markdown (#36009)

This commit is contained in:
Jinjing
2026-10-29 10:05:15 -07:00
committed by GitHub
parent 525719789f
commit e41105b5fc
2 changed files with 35 additions and 0 deletions
@@ -144,3 +144,34 @@ describe('MonacoEditor system theme', () => {
expect(editorProps.current?.theme).toBe('vs')
})
})
it('updates Unicode highlighting when the editor language changes', () => {
installMatchMedia(false)
const props = {
fileId: 'file',
filePath: '/repo/file.md',
viewStateKey: 'pane:file',
relativePath: 'file.md',
content: '中文说明:( example )\u200b',
onContentChange: vi.fn(),
onSave: vi.fn()
}
const view = render(<MonacoEditor {...props} language="markdown" />)
expect(editorProps.current?.options).toEqual(
expect.objectContaining({
unicodeHighlight: { ambiguousCharacters: false, invisibleCharacters: true }
})
)
view.rerender(<MonacoEditor {...props} language="typescript" />)
expect(editorProps.current?.options).toEqual(
expect.objectContaining({
unicodeHighlight: { ambiguousCharacters: true, invisibleCharacters: true }
})
)
view.rerender(<MonacoEditor {...props} language="markdown" />)
expect(editorProps.current?.options).toEqual(
expect.objectContaining({
unicodeHighlight: { ambiguousCharacters: false, invisibleCharacters: true }
})
)
})
@@ -306,6 +306,10 @@ export default function MonacoEditor({
lineNumbers: 'on',
renderLineHighlight: 'line',
automaticLayout: true,
unicodeHighlight: {
ambiguousCharacters: language !== 'markdown',
invisibleCharacters: true
},
tabSize: 2,
readOnly,
scrollbar: autoHeight