@@ -45,6 +45,7 @@ Command.dataElements = [];
4545Command . matches = [ ] ;
4646Command . customCommands = { } ;
4747Command . lastInputValue = '' ;
48+ Command . completionsNeedUpdate = false ;
4849
4950Command . setupFrameElements = function ( ) {
5051 this . bar = document . createElement ( 'div' ) ;
@@ -180,12 +181,17 @@ Command.completionOrder = {
180181 }
181182} ;
182183
184+ Command . markCompletionsForUpdate = function ( ) {
185+ this . completionsNeedUpdate = true ;
186+ } ;
187+
183188Command . updateCompletions = function ( useStyles ) {
184189 if ( ! window . isCommandFrame )
185190 return ;
186191 this . completionResults = [ ] ;
187192 this . dataElements = [ ] ;
188193 this . data . innerHTML = '' ;
194+ this . completionsNeedUpdate = false ;
189195 var key , i ;
190196 var completionKeys = Object . keys ( this . completions ) . sort ( function ( a , b ) {
191197 return this . completionOrder . getImportance ( b ) -
@@ -311,18 +317,18 @@ Command.callCompletionFunction = (function() {
311317 ] ) ;
312318 }
313319 }
314- self . updateCompletions ( true ) ;
320+ self . markCompletionsForUpdate ( ) ;
315321 self . completions . topsites = Search . topSites . filter ( function ( e ) {
316322 return ~ ( e [ 0 ] + ' ' + e [ 1 ] ) . toLowerCase ( )
317323 . indexOf ( search . slice ( 0 ) . join ( ' ' ) . toLowerCase ( ) ) ;
318324 } ) . slice ( 0 , 5 ) . map ( function ( e ) {
319325 return [ e [ 0 ] , e [ 1 ] ] ;
320326 } ) ;
321- self . updateCompletions ( true ) ;
327+ self . markCompletionsForUpdate ( ) ;
322328 if ( search . length ) {
323329 Marks . match ( search . join ( ' ' ) , function ( response ) {
324330 self . completions . bookmarks = response ;
325- self . updateCompletions ( true ) ;
331+ self . markCompletionsForUpdate ( ) ;
326332 } , 2 ) ;
327333 }
328334 self . historyMode = false ;
@@ -343,7 +349,7 @@ Command.callCompletionFunction = (function() {
343349 Complete . hasOwnProperty ( search [ 0 ] ) ) {
344350 Complete [ search [ 0 ] ] ( search . slice ( 1 ) . join ( ' ' ) , function ( response ) {
345351 self . completions = { search : response } ;
346- self . updateCompletions ( ) ;
352+ self . markCompletionsForUpdate ( ) ;
347353 } ) ;
348354 }
349355 } ;
@@ -357,7 +363,7 @@ Command.callCompletionFunction = (function() {
357363 limit : settings . searchlimit
358364 } )
359365 } ;
360- self . updateCompletions ( ) ;
366+ self . markCompletionsForUpdate ( ) ;
361367 } ) ;
362368 } ;
363369
@@ -373,7 +379,7 @@ Command.callCompletionFunction = (function() {
373379 . indexOf ( value . replace ( / ^ \S + \s + / , '' ) . toLowerCase ( ) ) ;
374380 } )
375381 } ;
376- self . updateCompletions ( ) ;
382+ self . markCompletionsForUpdate ( ) ;
377383 } ) ;
378384 } ;
379385
@@ -393,7 +399,7 @@ Command.callCompletionFunction = (function() {
393399 return e [ 0 ] . substring ( 0 , search . length ) === search ;
394400 } )
395401 } ;
396- self . updateCompletions ( ) ;
402+ self . markCompletionsForUpdate ( ) ;
397403 } ;
398404
399405 return function ( value ) {
@@ -410,7 +416,7 @@ Command.callCompletionFunction = (function() {
410416 case 'chrome' :
411417 Search . chromeMatch ( search , function ( matches ) {
412418 self . completions = { chrome : matches } ;
413- self . updateCompletions ( ) ;
419+ self . markCompletionsForUpdate ( ) ;
414420 } ) ;
415421 return true ;
416422 case 'tabhistory' :
@@ -431,7 +437,7 @@ Command.callCompletionFunction = (function() {
431437 } )
432438 } ;
433439 Command . completions . windows . unshift ( [ '0 (New window)' , '' ] ) ;
434- Command . updateCompletions ( ) ;
440+ Command . markCompletionsForUpdate ( ) ;
435441 }
436442 } ) ;
437443 self . completions = { } ;
@@ -450,7 +456,7 @@ Command.callCompletionFunction = (function() {
450456 case 'set' :
451457 Search . settingsMatch ( search , function ( matches ) {
452458 self . completions = { settings : matches } ;
453- self . updateCompletions ( ) ;
459+ self . markCompletionsForUpdate ( ) ;
454460 } ) ;
455461 return true ;
456462 case 'let' : // TODO
@@ -476,7 +482,7 @@ Command.callCompletionFunction = (function() {
476482 }
477483 Marks . match ( search , function ( response ) {
478484 self . completions . bookmarks = response ;
479- self . updateCompletions ( ) ;
485+ self . markCompletionsForUpdate ( ) ;
480486 } ) ;
481487 return true ;
482488 }
@@ -500,7 +506,7 @@ Command.complete = function(value) {
500506 return originalValue === element [ 0 ] . slice ( 0 , originalValue . length ) ;
501507 } )
502508 } ;
503- this . updateCompletions ( ) ;
509+ this . markCompletionsForUpdate ( ) ;
504510} ;
505511
506512Command . execute = function ( value , repeats ) {
0 commit comments