@@ -292,18 +292,16 @@ define(function (require, exports, module) {
292292 if ( currentPlugin ) {
293293 currentPlugin . itemSelect ( selectedItem , query ) ;
294294 } else {
295- // extract line number, if any
295+ // Extract line/col number, if any
296296 var cursorPos = extractCursorPos ( query ) ;
297297
298298 // Navigate to file and line number
299299 var fullPath = selectedItem && selectedItem . fullPath ;
300300 if ( fullPath ) {
301- // This case is tricky. We want to switch editors, so we need to deal with
302- // resizing/rescrolling the current editor first. But we don't actually want
303- // to start the animation of the ModalBar until afterward (otherwise it glitches
304- // because it gets starved of cycles during the creation of the new editor).
305- // So we call `prepareClose()` first, and finish the close later.
306- // FIXME: what about this case??
301+ // We need to fix up the current editor's scroll pos before switching to the next one. But if
302+ // we run the full close() now, ModalBar's animate-out won't be smooth (gets starved of cycles
303+ // during creation of the new editor). So we call prepareClose() to do *only* the scroll pos
304+ // fixup, and let the full close() be triggered later when the new editor takes focus.
307305 doClose = false ;
308306 this . modalBar . prepareClose ( ) ;
309307 CommandManager . execute ( Commands . CMD_ADD_TO_WORKINGSET_AND_OPEN , { fullPath : fullPath } )
@@ -312,9 +310,6 @@ define(function (require, exports, module) {
312310 var editor = EditorManager . getCurrentFullEditor ( ) ;
313311 editor . setCursorPos ( cursorPos . line , cursorPos . ch , true ) ;
314312 }
315- } )
316- . always ( function ( ) {
317- self . close ( ) ;
318313 } ) ;
319314 } else if ( cursorPos ) {
320315 EditorManager . getCurrentFullEditor ( ) . setCursorPos ( cursorPos . line , cursorPos . ch , true ) ;
@@ -338,13 +333,13 @@ define(function (require, exports, module) {
338333 } ;
339334
340335 /**
341- * Make sure ModalBar doesn't restore the scroll pos in cases where we're doing our own restoring instead.
336+ * Make sure ModalBar doesn't touch the scroll pos in cases where we're doing our own restoring instead.
342337 */
343338 QuickNavigateDialog . prototype . _handleBeforeClose = function ( reason ) {
344339 console . log ( "QuickOpen._handleBeforeClose()" , this . isOpen , this . closePromise , reason ) ;
345340 if ( reason === ModalBar . CLOSE_ESCAPE ) {
346- // Don't actually restore scroll pos yet though: wait for _handleCloseBar() when the editor has
347- // been resized back to its original height, matching the state it was in when we saved the pos.
341+ // Don't let ModalBar adjust scroll pos: we're going to revert it to its original pos. (In _handleCloseBar(),
342+ // when the editor has been resized back to its original height, matching state when we saved the pos)
348343 return { restoreScrollPos : false } ;
349344 }
350345 } ;
@@ -378,13 +373,13 @@ define(function (require, exports, module) {
378373 }
379374 }
380375
381- // Close popup & ensure we avoid any still-pending result promises
376+ // Close popup & ensure we ignore any still-pending result promises
382377 this . searchField . destroy ( ) ;
383378
384379 // Restore original selection / scroll pos if closed via Escape
385380 if ( reason === ModalBar . CLOSE_ESCAPE ) {
386381 console . log ( "QO restoring pos" ) ;
387- // We reset the scroll position synchronously on the ModalBar "close" event (before the animation
382+ // We can reset the scroll position synchronously on the ModalBar "close" event (before the animation
388383 // completes) since the editor has already been resized at this point.
389384 var editor = EditorManager . getCurrentFullEditor ( ) ;
390385 if ( this . _origSelection ) {
@@ -617,7 +612,7 @@ define(function (require, exports, module) {
617612 initialString = initialString || "" ;
618613 initialString = prefix + initialString ;
619614
620- this . searchField . setText ( initialString , true ) ;
615+ this . searchField . setText ( initialString ) ;
621616
622617 // Select just the text after the prefix
623618 this . $searchField [ 0 ] . setSelectionRange ( prefix . length , initialString . length ) ;
@@ -680,11 +675,10 @@ define(function (require, exports, module) {
680675 $ ( this . modalBar ) . on ( "close" , this . _handleCloseBar ) ;
681676
682677 this . $searchField = $ ( "input#quickOpenSearch" ) ;
683- this . $searchField . keyup ( this . _handleKeyUp ) ;
684678
685679 this . searchField = new QuickSearchField ( this . $searchField , {
686680 maxResults : 20 ,
687- verticalAdjust : this . modalBar . getRoot ( ) . outerHeight ( ) , // FIXME: hide popup until animation done! (setExtraDropdownCSS()?)
681+ verticalAdjust : this . modalBar . getRoot ( ) . outerHeight ( ) ,
688682 resultProvider : this . _filterCallback ,
689683 formatter : this . _resultsFormatterCallback ,
690684 onCommit : this . _handleItemSelect ,
0 commit comments