Last modified: 2014-08-20 17:55:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T70597, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 68597 - VisualEditor: Typing at the beginning of the document pulls annotations from the right; should instead be null
VisualEditor: Typing at the beginning of the document pulls annotations from ...
Status: RESOLVED FIXED
Product: VisualEditor
Classification: Unclassified
Data Model (Other open bugs)
unspecified
All All
: High normal
: VE-deploy-2014-08-21
Assigned To: Ed Sanders
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-26 01:21 UTC by Roan Kattouw
Modified: 2014-08-20 17:55 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Roan Kattouw 2014-07-26 01:21:43 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.
Comment 1 Gerrit Notification Bot 2014-07-29 01:56:09 UTC
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
Comment 2 Gerrit Notification Bot 2014-07-29 20:18:00 UTC
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
Comment 3 Gerrit Notification Bot 2014-07-29 20:22:55 UTC
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
Comment 4 Gerrit Notification Bot 2014-08-20 17:52:40 UTC
Change 155260 had a related patch set uploaded by Catrope:
Fix check for left/right annotations

https://gerrit.wikimedia.org/r/155260
Comment 5 Gerrit Notification Bot 2014-08-20 17:52:59 UTC
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
Comment 6 Gerrit Notification Bot 2014-08-20 17:55:31 UTC
Change 155260 merged by jenkins-bot:
Fix check for left/right annotations

https://gerrit.wikimedia.org/r/155260

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links