Skip to content

Commit 97cada6

Browse files
committed
chore: merge subs add in Minimap
1 parent 5380ba1 commit 97cada6

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed

lib/minimap.js

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -234,49 +234,54 @@ export default class Minimap {
234234
const subs = this.subscriptions
235235
let configSubscription = this.subscribeToConfig()
236236

237-
subs.add(configSubscription)
238-
239-
subs.add(this.textEditor.onDidChangeGrammar(() => {
240-
subs.remove(configSubscription)
241-
configSubscription.dispose()
242-
243-
configSubscription = this.subscribeToConfig()
244-
subs.add(configSubscription)
245-
}))
237+
subs.add(
238+
configSubscription,
239+
240+
this.textEditor.onDidChangeGrammar(() => {
241+
subs.remove(configSubscription)
242+
configSubscription.dispose()
243+
244+
configSubscription = this.subscribeToConfig()
245+
subs.add(configSubscription)
246+
}),
247+
248+
this.adapter.onDidChangeScrollTop(() => {
249+
if (!this.standAlone && !this.ignoreTextEditorScroll && !this.inChangeScrollTop) {
250+
this.inChangeScrollTop = true
251+
this.updateScrollTop()
252+
this.emitter.emit('did-change-scroll-top', this)
253+
this.inChangeScrollTop = false
254+
}
246255

247-
subs.add(this.adapter.onDidChangeScrollTop(() => {
248-
if (!this.standAlone && !this.ignoreTextEditorScroll && !this.inChangeScrollTop) {
249-
this.inChangeScrollTop = true
250-
this.updateScrollTop()
251-
this.emitter.emit('did-change-scroll-top', this)
252-
this.inChangeScrollTop = false
253-
}
256+
if (this.ignoreTextEditorScroll) {
257+
this.ignoreTextEditorScroll = false
258+
}
259+
}),
254260

255-
if (this.ignoreTextEditorScroll) {
256-
this.ignoreTextEditorScroll = false
257-
}
258-
}))
259-
subs.add(this.adapter.onDidChangeScrollLeft(() => {
260-
if (!this.standAlone) {
261-
this.emitter.emit('did-change-scroll-left', this)
262-
}
263-
}))
261+
this.adapter.onDidChangeScrollLeft(() => {
262+
if (!this.standAlone) {
263+
this.emitter.emit('did-change-scroll-left', this)
264+
}
265+
}),
266+
267+
this.textEditor.onDidChange((changes) => {
268+
this.scheduleChanges(changes)
269+
}),
270+
271+
this.textEditor.onDidDestroy(() => { this.destroy() }),
272+
273+
/*
274+
FIXME Some changes occuring during the tokenization produces
275+
ranges that deceive the canvas rendering by making some
276+
lines at the end of the buffer intact while they are in fact not,
277+
resulting in extra lines appearing at the end of the minimap.
278+
Forcing a whole repaint to fix that bug is suboptimal but works.
279+
*/
280+
this.textEditor.onDidTokenize(() => {
281+
this.emitter.emit('did-change-config')
282+
})
264283

265-
subs.add(this.textEditor.onDidChange((changes) => {
266-
this.scheduleChanges(changes)
267-
}))
268-
subs.add(this.textEditor.onDidDestroy(() => { this.destroy() }))
269-
270-
/*
271-
FIXME Some changes occuring during the tokenization produces
272-
ranges that deceive the canvas rendering by making some
273-
lines at the end of the buffer intact while they are in fact not,
274-
resulting in extra lines appearing at the end of the minimap.
275-
Forcing a whole repaint to fix that bug is suboptimal but works.
276-
*/
277-
subs.add(this.textEditor.onDidTokenize(() => {
278-
this.emitter.emit('did-change-config')
279-
}))
284+
)
280285
}
281286

282287
/**

0 commit comments

Comments
 (0)