mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Return containing tags from seek in the correct order
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
"sinon": "1.17.4",
|
||||
"temp": "^0.8.3",
|
||||
"text-buffer": "13.14.5",
|
||||
"tree-sitter": "0.12.20-1",
|
||||
"tree-sitter": "0.12.20",
|
||||
"typescript-simple": "1.0.0",
|
||||
"underscore-plus": "^1.6.8",
|
||||
"winreg": "^1.2.1",
|
||||
|
||||
@@ -512,7 +512,10 @@ class LanguageLayer {
|
||||
let includedRanges = null
|
||||
if (nodeRangeSet) {
|
||||
includedRanges = nodeRangeSet.getRanges()
|
||||
if (includedRanges.length === 0) return
|
||||
if (includedRanges.length === 0) {
|
||||
this.tree = null
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let affectedRange = this.editedRange
|
||||
@@ -650,13 +653,13 @@ class HighlightIterator {
|
||||
}
|
||||
|
||||
seek (targetPosition) {
|
||||
const openScopes = []
|
||||
const containingTags = [], containingTagStartIndices = []
|
||||
const targetIndex = this.languageMode.buffer.characterIndexForPosition(targetPosition)
|
||||
for (let i = this.iterators.length - 1; i >= 0; i--) {
|
||||
openScopes.push(...this.iterators[i].seek(targetIndex))
|
||||
this.iterators[i].seek(targetIndex, containingTags, containingTagStartIndices)
|
||||
}
|
||||
this.iterators.sort((a, b) => b.getIndex() - a.getIndex())
|
||||
return openScopes
|
||||
return containingTags
|
||||
}
|
||||
|
||||
moveToSuccessor () {
|
||||
@@ -702,11 +705,9 @@ class LayerHighlightIterator {
|
||||
this.openTags = []
|
||||
}
|
||||
|
||||
seek (targetIndex) {
|
||||
seek (targetIndex, containingTags, containingTagStartIndices) {
|
||||
while (this.treeCursor.gotoParent()) {}
|
||||
|
||||
const containingTags = []
|
||||
|
||||
this.done = false
|
||||
this.atEnd = true
|
||||
this.closeTags.length = 0
|
||||
@@ -717,7 +718,7 @@ class LayerHighlightIterator {
|
||||
|
||||
if (targetIndex >= this.treeCursor.endIndex) {
|
||||
this.done = true
|
||||
return containingTags
|
||||
return
|
||||
}
|
||||
|
||||
let childIndex = -1
|
||||
@@ -730,7 +731,7 @@ class LayerHighlightIterator {
|
||||
if (scopeName) {
|
||||
const id = this.idForScope(scopeName)
|
||||
if (this.treeCursor.startIndex < targetIndex) {
|
||||
containingTags.push(id)
|
||||
insertContainingTag(id, this.treeCursor.startIndex, containingTags, containingTagStartIndices)
|
||||
} else {
|
||||
this.atEnd = false
|
||||
this.openTags.push(id)
|
||||
@@ -940,6 +941,17 @@ class NodeRangeSet {
|
||||
}
|
||||
}
|
||||
|
||||
function insertContainingTag (tag, index, tags, indices) {
|
||||
const i = indices.findIndex(existingIndex => existingIndex > index)
|
||||
if (i === -1) {
|
||||
tags.push(tag)
|
||||
indices.push(index)
|
||||
} else {
|
||||
tags.splice(i, 0, tag)
|
||||
indices.splice(i, 0, index)
|
||||
}
|
||||
}
|
||||
|
||||
// Return true iff `mouse` is smaller than `house`. Only correct if
|
||||
// mouse and house overlap.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user