Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #324 from atom/as-dont-watch-same-editor
Browse files Browse the repository at this point in the history
Don't watch editors more than once if they're re-added to the workspace
  • Loading branch information
Antonio Scandurra authored Oct 21, 2017
2 parents 32472c0 + 721d19c commit a592c90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ BracketMatcher = require './bracket-matcher'

module.exports =
activate: ->
watchedEditors = new WeakSet()

atom.workspace.observeTextEditors (editor) ->
return if watchedEditors.has(editor)

editorElement = atom.views.getView(editor)
matchManager = new MatchManager(editor, editorElement)
new BracketMatcherView(editor, editorElement, matchManager)
new BracketMatcher(editor, editorElement, matchManager)
watchedEditors.add(editor)
editor.onDidDestroy -> watchedEditors.delete(editor)

0 comments on commit a592c90

Please sign in to comment.