Skip to content

Commit

Permalink
feat: limit the number of tokens that are rendered for one line This …
Browse files Browse the repository at this point in the history
…will prevent the very long lines to break minimap when softwrap is not enabled.
  • Loading branch information
aminya committed Nov 21, 2020
1 parent 53ef5e1 commit 85a56e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/mixins/canvas-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ module.exports = class CanvasDrawer extends Mixin {
*/
this.pendingFrontDecorationChanges = []
}

// the maximum number of tokens to render in one line
this.maxTokensInOneLine = atom.config.get("minimap.maxTokensInOneLine")
}

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

for (let row = startRow; row < endRow; row++) {
editor.tokensForScreenRow(row).forEach(token => {
const editorTokensForScreenRow = editor.tokensForScreenRow(row)
const numToken = editorTokensForScreenRow.length
const numTokenToRender = Math.min(numToken, this.maxTokensInOneLine);
for (let iToken = 0; iToken < numTokenToRender; iToken++) {
const token = editorTokensForScreenRow[iToken]
callback(row, {
text: token.text.replace(invisibleRegExp, ' '),
scopes: token.scopes
})
})
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@
"default": 300,
"description": "The duration of scrolling animations when clicking on the minimap.",
"order": 24
},
"maxTokensInOneLine": {
"type": "integer",
"default": 160,
"description": "The maximum number of tokens that are rendered for each line.",
"order": 25
}
},
"dependencies": {
Expand Down

0 comments on commit 85a56e3

Please sign in to comment.