Skip to content

Commit 1a9431b

Browse files
authored
Merge pull request #718 from atom-ide-community/limit-line-tokens-4upstream
2 parents f05ce88 + 4bbb4f8 commit 1a9431b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/mixins/canvas-drawer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ module.exports = class CanvasDrawer extends Mixin {
5959
*/
6060
this.pendingFrontDecorationChanges = []
6161
}
62+
63+
// the maximum number of tokens to render in one line
64+
this.maxTokensInOneLine = atom.config.get('minimap.maxTokensInOneLine')
6265
}
6366

6467
/**
@@ -416,12 +419,16 @@ module.exports = class CanvasDrawer extends Mixin {
416419
endRow = Math.min(endRow, editor.getScreenLineCount())
417420

418421
for (let row = startRow; row < endRow; row++) {
419-
editor.tokensForScreenRow(row).forEach(token => {
422+
const editorTokensForScreenRow = editor.tokensForScreenRow(row)
423+
const numToken = editorTokensForScreenRow.length
424+
const numTokenToRender = Math.min(numToken, this.maxTokensInOneLine)
425+
for (let iToken = 0; iToken < numTokenToRender; iToken++) {
426+
const token = editorTokensForScreenRow[iToken]
420427
callback(row, {
421428
text: token.text.replace(invisibleRegExp, ' '),
422429
scopes: token.scopes
423430
})
424-
})
431+
}
425432
}
426433
}
427434

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@
194194
"default": 300,
195195
"description": "The duration of scrolling animations when clicking on the minimap.",
196196
"order": 24
197+
},
198+
"maxTokensInOneLine": {
199+
"type": "integer",
200+
"default": 160,
201+
"description": "The maximum number of tokens that are rendered for each line.",
202+
"order": 25
197203
}
198204
},
199205
"dependencies": {

0 commit comments

Comments
 (0)