Last modified: 2014-08-20 17:55:31 UTC
1. Create a document with two paragraphs, and make both of them entirely bold 2. Put the cursor at the beginning of the first paragraph, and type a character. This character will be bold 3. Put the cursor at the beginning of the second paragraph, and type a character. This character will not be bold #2 and #3 should be consistent. In fact, #2 *only* happens at the very start of the document, #3 happens everywhere else. The reason this is broken is that the code computing the new insertionAnnotations in ve.dm.Surface#setSelection by pulling from the left does not take paragraph boundaries into account at all. In case #3, it tries to pull from the left across the paragraph boundary, but because getAnnotationsFromOffset() doesn't work the way it thinks it does (the offset at the end of the first paragraph is a content offset, but getting its annotations returns an empty set) that doesn't work, and so text inserted at the beginning of this paragraph is not annotated. However, at the very start, the getRelativeContentOffset() call that computes the offset to the left bounces back and returns the offset to the right instead (1), so left === right, and we end up pulling from the right and bolding the inserted text. So really, the code is trying to achieve the wrong behavior (#2), but in most cases that breaks and we end up with the right behavior (#3). So the correct behavior is achieved completely by accident, except in one edge case where the code successfully achieves the wrong behavior.
Change 150120 had a related patch set uploaded by Alex Monk: Fix pulling of annotations when inserting new character at start of document https://gerrit.wikimedia.org/r/150120
Change 150120 abandoned by Alex Monk: Fix pulling of annotations when inserting new character at start of document Reason: Breaks other things. https://gerrit.wikimedia.org/r/150120
Change 150378 had a related patch set uploaded by Alex Monk: [WIP] Fix pulling of annotations when typing at the beginning of the document https://gerrit.wikimedia.org/r/150378
Change 155260 had a related patch set uploaded by Catrope: Fix check for left/right annotations https://gerrit.wikimedia.org/r/155260
Change 150378 abandoned by Catrope: Fix pulling of annotations when typing at the beginning of the document Reason: https://gerrit.wikimedia.org/r/155260 fixes this bug https://gerrit.wikimedia.org/r/150378
Change 155260 merged by jenkins-bot: Fix check for left/right annotations https://gerrit.wikimedia.org/r/155260