Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/bracket-matcher-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,14 @@ class BracketMatcherView {
this.editor.buffer.getLanguageMode().getSyntaxNodeContainingRange(range, node => {
if (node.type.includes('element') && node.childCount > 0) {
const {firstChild, lastChild} = node
if (
firstChild.childCount > 2 &&
firstChild.firstChild.type === '<'
) {
if (firstChild.childCount > 2 && firstChild.firstChild.type === '<') {
if (lastChild === firstChild && firstChild.lastChild.type === '/>') {
startTag = firstChild
endTag = firstChild
} else if (
lastChild.childCount > 2 &&
(lastChild.firstChild.type === '</' ||
lastChild.firstChild.type === '<' && lastChild.child(1).type === '/')
(lastChild.firstChild.type === '<' && lastChild.child(1).type === '/'))
) {
startTag = firstChild
endTag = lastChild
Expand Down
2 changes: 2 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ module.exports = {

const editorElement = atom.views.getView(editor)
const matchManager = new MatchManager(editor, editorElement)
/* eslint-disable no-new */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't care about those objects? Shouldn't they be tracked?

From what I'm seeing both of those create subscriptions so they will stick around until Atom closes if we aren't tracking them.

Copy link
Contributor Author

@winstliu winstliu Mar 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like it, as we do track them within the classes and dispose them when each editor is closed. We should, however, also delete them when bracket-matcher is deactivated.

I think that might be outside of the scope of this pull request. What I can do is fix that first in a separate PR and then merge this one.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to make a PR a while ago to cleanly deactivate, but didn't want to get into the WeakSet stuff. It wasn't until recently I realised we could just iterate all current editors instead of trying to track what's in a WeakSet (I didn't want to convert to a normal set because I didn't know why a weak one was used in the first place).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I could take a stab at it and see how much progress I can make :).

new BracketMatcherView(editor, editorElement, matchManager)
new BracketMatcher(editor, editorElement, matchManager)
/* eslint-enable no-new */
watchedEditors.add(editor)
editor.onDidDestroy(() => watchedEditors.delete(editor))
})
Expand Down
3 changes: 3 additions & 0 deletions lib/tag-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class TagFinder {
this.editor.backwardsScanInBufferRange(pattern, scanRange, ({match, range, stop}) => {
if (this.isRangeCommented(range)) return

// eslint-disable-next-line no-unused-vars
const [entireMatch, isStartTag, tagName, attributes, suffix, isSelfClosingTag, isEndTag] = match

if (isSelfClosingTag) return
Expand Down Expand Up @@ -118,6 +119,7 @@ class TagFinder {
this.editor.scanInBufferRange(pattern, scanRange, ({match, range, stop}) => {
if (this.isRangeCommented(range)) return

// eslint-disable-next-line no-unused-vars
const [entireMatch, isStartTag, tagName, attributes, suffix, isSelfClosingTag, isEndTag] = match

if (isSelfClosingTag) return
Expand Down Expand Up @@ -146,6 +148,7 @@ class TagFinder {
this.editor.backwardsScanInBufferRange(this.tagPattern, [[0, 0], endPosition], ({match, range, stop}) => {
stop()

// eslint-disable-next-line no-unused-vars
const [entireMatch, prefix, isClosingTag, tagName, attributes, suffix, isSelfClosingTag] = Array.from(match)

let startRange = range
Expand Down
Loading