Work in progress - debugging getActiveHighlights in connection with next/previous

pull/3094/head
ninabreznik 7 years ago committed by yann300
parent e785308384
commit f49a693634
  1. 49
      src/app/editor/contextView.js
  2. 3
      src/app/editor/contextualListener.js

@ -115,7 +115,6 @@ class ContextView {
}
_render (node) {
console.log('rendering')
if (!node) return yo`<div></div>`
var self = this
var references = this._api.contextualListener.referencesOf(node)
@ -132,26 +131,44 @@ class ContextView {
}
function next () {
var currentName = node.attributes.name
if (currentName === this.refName) {
this.ref = this.ref === undefined ? 0 : this.ref
} else { this.ref = 0 }
var nodes = self._api.contextualListener.getActiveHighlights()
self._api.jumpTo(nodes[this.ref].position)
this.ref = (this.ref + 1) % nodes.length
this.refName = currentName
var currentName = node.attributes.name
var position = self.sourceMappingDecoder.decode(node.src)
if (currentName !== self.refName) self.ref = 0
var k = self.ref
/// LOGS ///
nodes.forEach(node => console.log(node.position.start))
console.log('----')
console.log(k)
console.log('----')
var pos = nodes[k].position
self._api.jumpTo(pos)
self.ref = (self.ref + 1) % nodes.length
self.refName = currentName
}
function previous () {
var currentName = node.attributes.name
if (currentName === this.refName) {
this.ref = this.ref === undefined ? 0 : this.ref
} else { this.ref = 0 } // should be this.ref = ref of the selected node (loop through all nodes to find this one)
var nodes = self._api.contextualListener.getActiveHighlights()
this.ref = this.ref === undefined ? 0 : this.ref
self._api.jumpTo(nodes[nodes.length - 1 - this.ref].position)
this.ref = (this.ref + 1) % nodes.length
this.refName = currentName
var currentName = node.attributes.name
if (currentName !== self.refName) self.ref = nodes.length - 1
var k = nodes.length - 1 - self.ref
/// LOGS ///
nodes.forEach(node => console.log(node.position.start))
console.log('----')
console.log(k)
console.log('----')
var pos = nodes[k].position
self._api.jumpTo(pos)
self.ref = (self.ref + 1) % nodes.length
self.refName = currentName
}
return yo`<div class=${css.line}>

@ -39,6 +39,9 @@ class ContextualListener {
getActiveHighlights () {
return [...this._activeHighlights]
// return [...this._activeHighlights].sort((a,b) => {
// return a.position.start - b.position.start
// })
}
declarationOf (node) {

Loading…
Cancel
Save