mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 07:30:05 +00:00
Restore focus also when switching syntax highlighting on
The same already happens when switching it off, see line #249. I noticed there is still a (random?) chance the selection gets lost when switching back and forth between syntax highlighting on and off. This is not what this patch is about. Bug: T298488 Change-Id: I541f96be9e6fb2f9032df4b86657d01f0eac5679
This commit is contained in:
parent
92051b550f
commit
963e636f83
|
@ -112,7 +112,8 @@
|
|||
var $codeMirror, cmOptions,
|
||||
selectionStart = $textbox1.prop( 'selectionStart' ),
|
||||
selectionEnd = $textbox1.prop( 'selectionEnd' ),
|
||||
scrollTop = $textbox1.scrollTop();
|
||||
scrollTop = $textbox1.scrollTop(),
|
||||
hasFocus = $textbox1.is( ':focus' );
|
||||
|
||||
// If CodeMirror is already loaded or wikEd gadget is enabled, abort. See T178348.
|
||||
// FIXME: Would be good to replace the wikEd check with something more generic.
|
||||
|
@ -168,6 +169,9 @@
|
|||
}
|
||||
} );
|
||||
|
||||
if ( hasFocus ) {
|
||||
codeMirror.focus();
|
||||
}
|
||||
codeMirror.doc.setSelection( codeMirror.doc.posFromIndex( selectionEnd ), codeMirror.doc.posFromIndex( selectionStart ) );
|
||||
codeMirror.scrollTo( null, scrollTop );
|
||||
|
||||
|
|
Loading…
Reference in a new issue