Skip to content

Commit

Permalink
fix: debounce provider.rebuildCache
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 27, 2021
1 parent 3ce936b commit 5b07a1d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/autocomplete-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ export { config } from "./config"
import PathsProvider from "./paths-provider"
import { CompositeDisposable } from "atom"
import { OptionScopes } from "./config/option-scopes"
import { debounce } from "underscore"

const subscriptions = new CompositeDisposable()
let _provider
/** provider.rebuildCache method debounced */
let _rebuildCache
let _statusBar
let _statusBarInterval
let _statusBarTile
Expand All @@ -16,7 +19,7 @@ export function activate() {
subscriptions.add(
atom.commands.add("atom-workspace", {
"autocomplete-paths:rebuild-cache": () => {
_provider.rebuildCache()
_rebuildCache()
},
})
)
Expand All @@ -36,7 +39,7 @@ export function activate() {
return
}
_provider._pathsCache.updateConfig()
_provider.rebuildCache()
_rebuildCache()
})
)
})
Expand Down Expand Up @@ -139,7 +142,10 @@ export function getProvider() {
_provider.on("rebuild-cache-done", () => {
_hideStatusBarTile()
})
_provider.rebuildCache()
_rebuildCache = debounce(() => {
_provider.rebuildCache()
}, 1000)
_rebuildCache()
}
return _provider
}

0 comments on commit 5b07a1d

Please sign in to comment.