Page MenuHomePhabricator

Cursor is placed incorrectly after inserting Hebrew diacritics
Closed, ResolvedPublic

Description

The vowel point is added correctly, but after it is added the cursor moves back to where it was. For example, let's take the word שבּת. Let's mark it like this:

  • ש = S
  • ב = B
  • ת = T

The dot inside ב is called a "dagesh"; i'll mark it as a period - .

The cursor = |

I type SBT and the cursor is now after the T: SBT| שבת

Now i move back one letter and the cursor is after the B: SB|T

Now i click the letter that is supposed to add the dagesh (it's the first one on the right.) The dagesh is added: SB|.T שבּ‏ת

Notice, however, that the cursor is still between the B and the dagesh, even though it is supposed to be after the dagesh. How do i know that it is before the dagesh? If i press the Del key, the the dagesh disappears - שבת. If i press the backspace, then the B disappears and the dagesh moves to the S - שּ‏ת. This is definitely wrong.

See also discussion here:

http://en.wikisource.org/wiki/MediaWiki_talk:Edittools#Hebrew_vowels_and_cantillation


Version: unspecified
Severity: minor
OS: Windows XP
Platform: PC
URL: http://www.mediawiki.org/wiki/Extension_talk:CharInsert

Details

Reference
bz16900

Related Objects

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:23 PM
bzimport added projects: CharInsert, I18n.
bzimport set Reference to bz16900.
bzimport added a subscriber: Unknown Object (MLST).

Can you add details of what browser/version/operating system you're using? Behavior may differ.

Amir, is this bug still remain in latest version of Firefox? Is this behavior vary across browsers/operating system?

Yes, it still remains. It is not very important, however, because the WikiEditor toolbar inserts these characters properly.

Now that i know the code better, i can try looking at this bug myself, but maybe this extension can just be retired...

matmarex subscribed.

There is indeed a bug here, but I believe it has never been in CharInsert – rather, it is a bug in https://he.wikipedia.org/wiki/מדיה_ויקי:Edittools.js (P6644) and other pages which copy-pasted code from it. It would also affect all combining marks, not just the Hebrew ones – you can reproduce the same issue when inserting a combining umlaut (U+0308) after a, for example.

Basically, browsers (except Chrome, curiously) allow the cursor to be programmatically placed between a character and its combining marks, even though it's normally not possible. When this code calls insertTags('', this.title, ''), passing the text to insert as the second parameter to mw.toolbar.insertTags (tagClose), the combining mark is inserted after the cursor and the cursor position is not changed. Therefore, the cursor is now between the character and the combining mark.

(These days, insertTags and mw.toolbar.insertTags are deprecated, but you will see the same result when directly calling $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', { post: ... } ).)

To avoid this, simply pass the text as the first parameter to mw.toolbar.insertTags (tagOpen), or as the pre parameter to textSelection/encapsulateSelection! This way it will be inserted before the cursor and everything will behave sanely.

I think I fixed this issue on Hebrew Wikipedia: https://he.wikipedia.org/w/index.php?title=מדיה_ויקי:Edittools.js&diff=22334021&oldid=14790224@Amire80, can you confirm that it is fixed?

Oh wow, one of my oldest!

This appears to work well, thanks!