r89858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89857‎ | r89858 | r89859 >
Date:23:09, 10 June 2011
Author:brion
Status:deferred
Tags:
Comment:
CodeEditor: fix to avoid selecting when inserting non-samples such as character insertions
Logging some stub func calls
Modified paths:
  • /trunk/extensions/CodeEditor/modules/jquery.codeEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeEditor/modules/jquery.codeEditor.js
@@ -75,8 +75,10 @@
7676 return;
7777 },
7878 'saveSelection': function() {
 79+ mw.log('codeEditor stub function saveSelection called');
7980 },
8081 'restoreSelection': function() {
 82+ mw.log('codeEditor stub function restoreSelection called');
8183 },
8284 /**
8385 * Sets up the iframe in place of the textarea to allow more advanced operations
@@ -152,6 +154,7 @@
153155 */
154156
155157 'getElementAtCursor': function() {
 158+ mw.log('codeEditor stub function getElementAtCursor called');
156159 },
157160
158161 /**
@@ -171,10 +174,10 @@
172175 var sel = context.codeEditor.getSelection();
173176 var range = sel.getRange();
174177 var selText = context.fn.getSelection();
175 - var selectAfter = false;
 178+ var isSample = false;
176179 if ( !selText ) {
177180 selText = options.peri;
178 - selectAfter = true;
 181+ isSample = true;
179182 } else if ( options.replace ) {
180183 selText = options.peri;
181184 }
@@ -182,7 +185,7 @@
183186 text += selText;
184187 text += options.post;
185188 context.codeEditor.insert( text );
186 - if ( selectAfter ) {
 189+ if ( isSample && options.selectPeri && !options.splitlines ) {
187190 // May esplode if anything has newlines, be warned. :)
188191 range.setStart( range.start.row, range.start.column + options.pre.length );
189192 range.setEnd( range.start.row, range.start.column + selText.length );
@@ -195,6 +198,7 @@
196199 * DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
197200 */
198201 'getCaretPosition': function( options ) {
 202+ mw.log('codeEditor stub function getCaretPosition called');
199203 },
200204 /**
201205 * Sets the selection of the content
@@ -237,7 +241,7 @@
238242 * DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
239243 */
240244 'scrollToCaretPosition': function( options ) {
241 - //context.fn.scrollToTop( context.fn.getElementAtCursor(), true );
 245+ mw.log('codeEditor stub function scrollToCaretPosition called');
242246 return context.$textarea;
243247 },
244248 /**
@@ -248,6 +252,7 @@
249253 * @param force If true, scroll the element even if it's already visible
250254 */
251255 'scrollToTop': function( $element, force ) {
 256+ mw.log('codeEditor stub function scrollToTop called');
252257 }
253258 } );
254259

Status & tagging log