Skip to content

Commit f0ce080

Browse files
committed
fix: use minimap methods in CanvasDrawer
1 parent 506c168 commit f0ce080

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/minimap-element.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,8 @@ class MinimapElement {
713713
*/
714714
setModel (minimap) {
715715
this.minimap = minimap
716+
// TODO: go direct
717+
this.CanvasDrawer.minimap = minimap
716718

717719
this.subscriptions.add(
718720

lib/mixins/canvas-drawer.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import CanvasLayer from '../canvas-layer'
1313
* methods are available on any `MinimapElement` instance.
1414
*/
1515
export default class CanvasDrawer {
16+
constructor() {
17+
// set in setModel of minimapElement
18+
this.minimap = undefined
19+
}
1620
/**
1721
* Initializes the canvas elements needed to perform the `Minimap` rendering.
1822
*/
@@ -401,8 +405,8 @@ export default class CanvasDrawer {
401405
* @access private
402406
*/
403407
eachTokenForScreenRows (startRow, endRow, callback) {
404-
const editor = this.getTextEditor()
405-
const invisibleRegExp = this.getInvisibleRegExp()
408+
const editor = this.minimap.getTextEditor()
409+
const invisibleRegExp = this.getInvisibleRegExp(editor)
406410
endRow = Math.min(endRow, editor.getScreenLineCount())
407411

408412
for (let row = startRow; row < endRow; row++) {
@@ -471,12 +475,12 @@ export default class CanvasDrawer {
471475
/**
472476
* Returns the regexp to replace invisibles substitution characters
473477
* in editor lines.
474-
*
478+
* @param {TextEditor} editor
475479
* @return {RegExp} the regular expression to match invisible characters
476480
* @access private
477481
*/
478-
getInvisibleRegExp () {
479-
const invisibles = this.getTextEditor().getInvisibles()
482+
getInvisibleRegExp (editor) {
483+
const invisibles = editor.getInvisibles()
480484
const regexp = []
481485
if (invisibles.cr != null) { regexp.push(invisibles.cr) }
482486
if (invisibles.eol != null) { regexp.push(invisibles.eol) }

0 commit comments

Comments
 (0)