adobe / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
33.25k stars 7.63k forks source link

Wrong cursor positioning with complex scrips #6301

Open santhoshtr opened 10 years ago

santhoshtr commented 10 years ago

Paste the following text to brackets, and see where the cursor is placed

സന്തോഷ്

Cursor is supposed to place at end of the word, but in brackets it is after 4 or 5 character width.

brackets

Happens with all non-latin complex scripts

peterflynn commented 10 years ago

Reproduces in vanilla CodeMirror too

santhoshtr commented 10 years ago

It seems bracket is placing the cursor based on the character count. The word സന്തോഷ് has 7 unicode characters. But the visual width is not 7 X character width. For complex scripts, the characters combine and form ligatures. Browsers can do this natively, overriding it using user level logic is bad idea.

njx commented 10 years ago

Doesn't seem to repro in CM in FF, so this might be a Chrome-only CM issue.

njx commented 10 years ago

To me to file against CM

santhoshtr commented 10 years ago

What is CM?

peterflynn commented 10 years ago

@santhoshtr CM is referring to CodeMirror, the code-editor UI widget that Brackets uses.

santhoshtr commented 10 years ago

Ok, reported there https://github.com/marijnh/CodeMirror/issues/2115

njx commented 10 years ago

FYI, it looks from the CM bug thread like Marijn has been trying to fix this, but is hampered by lack of a good way to detect grapheme clusters from JS. Maybe someone from Web Platform has some knowledge in this area?