Repository navigation
Conversation
Codecov Report❌ Patch coverage is 🚀 New features to boost your workflow:
|
|
@Goudarz Hi, this looks really interesting! Before I get too deep into reviewing the code, two questions: First, has the divergence with native/browser editors been reported upstream to CodeMirror as a bug? Its issue tracker is here, you can log in with your GitHub account. I didn't do this previously as I'd not investigated deep enough to find the root cause or a minimal reproduction (to verify that this isn't specific to our code only). It would be preferable for the You should be able to CC me there as Second, your comment above mentions
Is this intended as a reference to something specific? Just searching for the parenthetical text I wasn't able to find it, and I'd like to read more. |
04bccd7 to
15adc55
Compare
|
Thanks! I've now reported the This is the part that breaks arrow-key navigation. If it gets fixed in CodeMirror, then the explicit direction in decoratorPlugin.ts can be removed. The other issue—where typed text appears away from a click near a Persian/ boundary—isn't really a CodeMirror bug. Native contenteditable elements behave the way because a click at that point can map to two positions and which one is selected depends on what gets typed next. The reference is Murray Sargents post about the text insertion point: https://learn.microsoft.com/en-us/archive/blogs/murrays/text-insertion-point (section "BiDi text insertion points"). Native editors use the keyboard language to decide where to insert text. We can't detect the keyboard language, on the web so the PR uses the typed character instead. |
Fixes #2985
In RTL translations quoted values such as HTML attribute values used
dir="auto". The browser resolves that over the value while CodeMirror resolved it per segment between placeholders so arrow keys and clicks didn't match what was shown. The direction is now detected once. Set explicitly for both and it no longer flips while typing (for example adding a Persian word in front of an English one).There is also an ambiguity that BiDi text always has: next to a boundary between English text, one point on screen maps to two positions and which one shows the typed text depends on what you type. Native editors resolve this using the keyboard language (Murray Sargent "Text Insertion Point"). We can't detect that on the web so after a click the first typed character is placed at the nearby position where it actually shows up next to the click. Its measured on before input on lines that mix directions and the trial edits don't touch the undo history.
Tested in Firefox/Edge by clicking both edges of words and typing English letters in Persian, English and mixed values in Fluent and plain strings and, in an LTR locale.
Screenshots
Before / After