mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Fix exception when deleting all text (Ctrl+A Backspace)"
This commit is contained in:
commit
1c5ac9d502
|
@ -95,6 +95,7 @@ ve.dm.Surface.prototype.getFragment = function ( range, noAutoSelect ) {
|
||||||
* @param {ve.Range|undefined} selection
|
* @param {ve.Range|undefined} selection
|
||||||
*/
|
*/
|
||||||
ve.dm.Surface.prototype.change = function ( transactions, selection ) {
|
ve.dm.Surface.prototype.change = function ( transactions, selection ) {
|
||||||
|
var leftOffset, contentOffset, annotations;
|
||||||
if ( transactions ) {
|
if ( transactions ) {
|
||||||
if ( transactions instanceof ve.dm.Transaction ) {
|
if ( transactions instanceof ve.dm.Transaction ) {
|
||||||
transactions = [transactions];
|
transactions = [transactions];
|
||||||
|
@ -119,9 +120,16 @@ ve.dm.Surface.prototype.change = function ( transactions, selection ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear and add annotations to stack if insertingAnnotations isn't happening
|
// Clear and add annotations to stack if insertingAnnotations isn't happening
|
||||||
if (!this.insertingAnnotations) {
|
if ( !this.insertingAnnotations ) {
|
||||||
var contentOffset = this.documentModel.getNearestContentOffset( this.getSelection().start - 1, -1 ),
|
leftOffset = this.getSelection().start - 1;
|
||||||
annotations = this.documentModel.getAnnotationsFromOffset( contentOffset );
|
if ( leftOffset == -1 ) {
|
||||||
|
leftOffset = 0;
|
||||||
|
}
|
||||||
|
contentOffset = this.documentModel.getNearestContentOffset( leftOffset, -1 );
|
||||||
|
// contentOffset may be -1 if the document is empty
|
||||||
|
annotations = contentOffset > - 1 ?
|
||||||
|
this.documentModel.getAnnotationsFromOffset( contentOffset ) :
|
||||||
|
new ve.AnnotationSet();
|
||||||
|
|
||||||
// Reset insertAnnotations
|
// Reset insertAnnotations
|
||||||
this.documentModel.insertAnnotations = new ve.AnnotationSet();
|
this.documentModel.insertAnnotations = new ve.AnnotationSet();
|
||||||
|
|
Loading…
Reference in a new issue