https://bugzilla.wikimedia.org/show_bug.cgi?id=68597

            Bug ID: 68597
           Summary: VisualEditor: Typing at the beginning of the document
                    pulls annotations from the right
           Product: VisualEditor
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Data Model
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]
       Web browser: ---
   Mobile Platform: ---

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to