Skip to content

Commit

Permalink
feat: warn about poor performance if treesitter is off
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 7, 2021
1 parent 65de0e0 commit 67b60c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MinimapElement from './minimap-element'
import Minimap from './minimap'
import config from './config.json'
import * as PluginManagement from './plugin-management'
import { treeSitterWarning } from './performance-monitor'

export * as config from './config.json'
export * from './plugin-management'
Expand Down Expand Up @@ -349,13 +350,16 @@ export function observeMinimaps (iterator) {
* @access private
*/
function initSubscriptions () {
subscriptions.add(atom.workspace.observeTextEditors((textEditor) => {
const minimap = minimapForEditor(textEditor)
const minimapElement = atom.views.getView(minimap)

emitter.emit('did-create-minimap', minimap)
minimapElement.attach()
}))
subscriptions.add(
atom.workspace.observeTextEditors((textEditor) => {
const minimap = minimapForEditor(textEditor)
const minimapElement = atom.views.getView(minimap)

emitter.emit('did-create-minimap', minimap)
minimapElement.attach()
}),
treeSitterWarning()
)
}

// The public exports included in the service:
Expand Down
11 changes: 11 additions & 0 deletions lib/performance-monitor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// Functions used to recommend the configurations required for the best performance of Minimap

export function treeSitterWarning () {
return observeAndWarn(
'core.useTreeSitterParsers',
true,
'Tree-sitter is off (Low Performance Warning).',
`You should turn on Atom's tree-sitter parser to experience the best performance Minimap and Atom is deisgned for.
Keeping tree-sitter parser off results in sluggish scrolling and lags in the text editor.`
)
}

/* Utility function that observes a config and throws warnings once a day if it is not the recommended value */
function observeAndWarn (configName, recommendedValue, warningTitle, warningDescription) {
Expand Down

0 comments on commit 67b60c8

Please sign in to comment.