mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Merge pull request #5424 from tridactyl/completion_memleak_fix
Stop accumulating tab listeners, objects forever
This commit is contained in:
commit
debea430a0
|
|
@ -79,6 +79,7 @@ class BufferCompletionOption
|
|||
export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: BufferCompletionOption[]
|
||||
private shouldSetStateFromScore = true
|
||||
private removeTabChangesListener: () => void
|
||||
|
||||
// TODO:
|
||||
// - store the exstr and trigger redraws on user or data input without
|
||||
|
|
@ -109,7 +110,14 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
this.updateOptions()
|
||||
this._parent.appendChild(this.node)
|
||||
|
||||
Messaging.addListener("tab_changes", () => this.reactToTabChanges())
|
||||
this.removeTabChangesListener = Messaging.addListener(
|
||||
"tab_changes",
|
||||
() => this.reactToTabChanges(),
|
||||
)
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.removeTabChangesListener()
|
||||
}
|
||||
|
||||
async onInput(exstr) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ class TabAllCompletionOption
|
|||
extends Completions.CompletionOptionHTML
|
||||
implements Completions.CompletionOptionFuse {
|
||||
public fuseKeys = []
|
||||
public tab: browser.tabs.Tab
|
||||
constructor(
|
||||
public value: string,
|
||||
tab: browser.tabs.Tab,
|
||||
|
|
@ -25,7 +24,6 @@ class TabAllCompletionOption
|
|||
const valueStr = `${winindex}.${tab.index + 1}`
|
||||
this.value = valueStr
|
||||
this.fuseKeys.push(this.value, tab.title, tab.url)
|
||||
this.tab = tab
|
||||
|
||||
// pre contains max four uppercase characters for tab status.
|
||||
// If statusstylepretty is set to true replace use unicode characters,
|
||||
|
|
@ -88,6 +86,7 @@ class TabAllCompletionOption
|
|||
export class TabAllCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: TabAllCompletionOption[]
|
||||
private shouldSetStateFromScore = true
|
||||
private removeTabChangesListener: () => void
|
||||
|
||||
constructor(private _parent) {
|
||||
super(["taball", "tabgrab"], "TabAllCompletionSource", "All Tabs")
|
||||
|
|
@ -97,7 +96,14 @@ export class TabAllCompletionSource extends Completions.CompletionSourceFuse {
|
|||
this.shouldSetStateFromScore =
|
||||
config.get("completions", "TabAll", "autoselect") === "true"
|
||||
|
||||
Messaging.addListener("tab_changes", () => this.reactToTabChanges())
|
||||
this.removeTabChangesListener = Messaging.addListener(
|
||||
"tab_changes",
|
||||
() => this.reactToTabChanges(),
|
||||
)
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.removeTabChangesListener()
|
||||
}
|
||||
|
||||
async onInput(exstr) {
|
||||
|
|
|
|||
|
|
@ -137,9 +137,10 @@ export function getCommandlineFns(cmdline_state: {
|
|||
// Delete all completion sources - I don't think this is required, but this
|
||||
// way if there is a transient bug in completions it shouldn't persist.
|
||||
if (cmdline_state.activeCompletions)
|
||||
cmdline_state.activeCompletions.forEach(comp =>
|
||||
cmdline_state.completionsDiv.removeChild(comp.node),
|
||||
)
|
||||
cmdline_state.activeCompletions.forEach(comp => {
|
||||
comp.destroy?.()
|
||||
cmdline_state.completionsDiv.removeChild(comp.node)
|
||||
})
|
||||
cmdline_state.activeCompletions = undefined
|
||||
cmdline_state.isVisible = false
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue