diff --git a/lib/minimap.js b/lib/minimap.js index 0a390343..9c6cb07f 100644 --- a/lib/minimap.js +++ b/lib/minimap.js @@ -162,6 +162,15 @@ class Minimap { * @access private */ this.configDevicePixelRatioRounding = null + /** + * A number of milliseconds which determines how often the minimap should redraw itself after + * detecting changes in the text editor. A value of 0 will cause the minimap to redraw + * immediately. + * + * @type {number} + * @access private + */ + this.redrawDelay = 0 /** * A boolean value to store whether this Minimap have been destroyed or not. * @@ -305,10 +314,15 @@ class Minimap { scheduleChanges (changes) { this.pendingChangeEvents.push(...changes) - // If any changes happened within the timeout's delay, a timeout will already have been - // scheduled -> no need to schedule again + // Optimisation: If the redraw delay is set to 0, do not even schedule a timer + if (!this.redrawDelay) { + return this.flushChanges() + } + if (!this.flushChangesTimer) { - this.flushChangesTimer = setTimeout(() => { this.flushChanges() }, 1000) + // If any changes happened within the timeout's delay, a timeout will already have been + // scheduled -> no need to schedule again + this.flushChangesTimer = setTimeout(() => { this.flushChanges() }, this.redrawDelay) } } @@ -455,6 +469,9 @@ class Minimap { subs.add(atom.config.observe('minimap.scrollSensitivity', opts, (scrollSensitivity) => { this.scrollSensitivity = scrollSensitivity })) + subs.add(atom.config.observe('minimap.redrawDelay', opts, (redrawDelay) => { + this.redrawDelay = redrawDelay + })) // cdprr is shorthand for configDevicePixelRatioRounding subs.add(atom.config.observe( 'minimap.devicePixelRatioRounding', diff --git a/package.json b/package.json index 96c663eb..42bcb8c3 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,13 @@ "type": "boolean", "default": true }, + "redrawDelay": { + "type": "number", + "default": 0, + "minimum": 0, + "maximum": 1000, + "description": "Controls how often (in ms) the minimap should redraw itself after changing the text editor's contents. Setting this to 100ms or higher could dramatically improve editor responsiveness when working with large files. A value of 0 will cause the minimap to redraw itself immediately on each change." + }, "adjustMinimapWidthToSoftWrap": { "type": "boolean", "default": true,