From 6f6dfe78a9c1ab7a18655da92fda1f0cf813a0a9 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Kevin Sawicki Date: Wed, 12 Dec 2012 17:21:08 -0800 Subject: [PATCH] Clear timeout when select-list is cancelled --- src/app/select-list.coffee | 11 +++++++---- src/extensions/event-palette/src/event-palette.coffee | 4 +++- src/extensions/fuzzy-finder/src/fuzzy-finder.coffee | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/select-list.coffee b/src/app/select-list.coffee index 2bca8c3a9..36319c7c8 100644 --- a/src/app/select-list.coffee +++ b/src/app/select-list.coffee @@ -2,7 +2,6 @@ $ = require 'jquery' { View } = require 'space-pen' Editor = require 'editor' fuzzyFilter = require 'fuzzy-filter' -_ = require 'underscore' module.exports = class SelectList extends View @@ -16,6 +15,7 @@ class SelectList extends View @viewClass: -> 'select-list' maxItems: Infinity + scheduleTimeout: null inputThrottle: 200 filteredArray: null cancelling: false @@ -23,7 +23,7 @@ class SelectList extends View initialize: -> requireStylesheet 'select-list.css' - @miniEditor.getBuffer().on 'change', _.debounce((=> @populateList()), @inputThrottle) + @miniEditor.getBuffer().on 'change', => @schedulePopulateList() @miniEditor.on 'focusout', => @cancel() unless @cancelling @on 'core:move-up', => @selectPreviousItem() @on 'core:move-down', => @selectNextItem() @@ -38,6 +38,10 @@ class SelectList extends View @confirmSelection() if $(e.target).closest('li').hasClass('selected') e.preventDefault() + schedulePopulateList: -> + clearTimeout(@scheduleTimeout) + @scheduleTimeout = setTimeout((=> @populateList()), @inputThrottle) + setArray: (@array) -> @populateList() @selectItem(@list.find('li:first')) @@ -59,7 +63,6 @@ class SelectList extends View @loading.text(message).show() populateList: -> - return unless @hasParent() filterQuery = @miniEditor.getText() if filterQuery.length filteredArray = fuzzyFilter(@array, filterQuery, key: @filterKey) @@ -119,4 +122,4 @@ class SelectList extends View @cancelled() @detach() @cancelling = false - + clearTimeout(@scheduleTimeout) diff --git a/src/extensions/event-palette/src/event-palette.coffee b/src/extensions/event-palette/src/event-palette.coffee index fcd8dcdc1..b7eac9017 100644 --- a/src/extensions/event-palette/src/event-palette.coffee +++ b/src/extensions/event-palette/src/event-palette.coffee @@ -20,7 +20,9 @@ class EventPalette extends SelectList keyBindings: null initialize: (@rootView) -> - @command 'event-palette:toggle', => @cancel() + @command 'event-palette:toggle', => + @cancel() + false super attach: -> diff --git a/src/extensions/fuzzy-finder/src/fuzzy-finder.coffee b/src/extensions/fuzzy-finder/src/fuzzy-finder.coffee index 047190757..14b2441b0 100644 --- a/src/extensions/fuzzy-finder/src/fuzzy-finder.coffee +++ b/src/extensions/fuzzy-finder/src/fuzzy-finder.coffee @@ -41,8 +41,8 @@ class FuzzyFinder extends SelectList else return unless @rootView.project.getPath()? @allowActiveEditorChange = false - @attach() @populateProjectPaths() + @attach() toggleBufferFinder: -> if @hasParent()