hide highlight on focus change

pull/526/head
LianaHus 4 years ago
parent 9691b2cde5
commit 22febd28ad
  1. 1
      apps/remix-ide/src/app/components/side-panel.js
  2. 30
      apps/remix-ide/src/app/editor/SourceHighlighters.js
  3. 1
      apps/remix-ide/src/app/editor/contextualListener.js
  4. 5
      apps/remix-ide/src/app/editor/editor.js
  5. 1
      apps/remix-ide/src/app/editor/sourceHighlighter.js
  6. 2
      libs/remix-simulator/src/provider.js

@ -112,6 +112,7 @@ export class SidePanel extends AbstractPanel {
async showContent (name) {
super.showContent(name)
this.renderHeader()
this.focus(name)
}
/** The header of the side panel */

@ -1,9 +1,6 @@
'use strict'
const SourceHighlighter = require('./sourceHighlighter')
// EditorApi:
// - methods: ['highlight', 'discardHighlight'],
class SourceHighlighters {
constructor () {
@ -28,6 +25,24 @@ class SourceHighlighters {
}
}
highlightAllFrom (from) {
try {
if (!this.highlighters[from]) return
const sourceHighlight = new SourceHighlighter()
for (const index in this.highlighters[from]) {
sourceHighlight.currentSourceLocationFromfileName(
this.highlighters[from][index].position,
this.highlighters[from][index].filePath,
this.highlighters[from][index].hexColor
)
this.highlighters[from][index] = sourceHighlight
}
} catch (e) {
throw e
}
}
discardHighlight (from) {
if (this.highlighters[from]) {
for (const index in this.highlighters[from]) this.highlighters[from][index].currentSourceLocation(null)
@ -35,6 +50,15 @@ class SourceHighlighters {
this.highlighters[from] = []
}
hideHighlightsExcept (toStay) {
for (const highlighter in this.highlighters) {
for (const index in this.highlighters[highlighter]) {
this.highlighters[highlighter][index].currentSourceLocation(null)
}
this.highlightAllFrom(toStay)
}
}
discardHighlightAt (line, filePath, from) {
if (this.highlighters[from]) {
for (const index in this.highlighters[from]) {

@ -123,7 +123,6 @@ class ContextualListener extends Plugin {
}
_highlightInternal (position, node) {
console.log('highlighting______', node)
if (node.nodeType == 'Block') return
let lastCompilationResult = this._deps.compilersArtefacts['__last']
if (lastCompilationResult && lastCompilationResult.languageversion.indexOf('soljson') === 0) {

@ -189,7 +189,6 @@ class Editor extends Plugin {
this.editor.on('changeSession', () => {
this._onChange()
this.event.trigger('sessionSwitched', [])
this.editor.getSession().on('change', () => {
this._onChange()
this.event.trigger('contentChanged', [])
@ -197,6 +196,10 @@ class Editor extends Plugin {
})
}
onActivation () {
this.on('sidePanel', 'focusChanged', (name) => this.sourceHighlighters.hideHighlightsExcept(name))
}
highlight (position, filePath, hexColor) {
const { from } = this.currentRequest
this.sourceHighlighters.highlight(position, filePath, hexColor, from)

@ -39,6 +39,7 @@ class SourceHighlighter {
this.source = null
if (lineColumnPos) {
this.source = filePath
if (!this.source) this.source = this._deps.fileManager.currentFile()
if (this._deps.fileManager.currentFile() !== this.source) {
await this._deps.fileManager.open(this.source)
this.source = this._deps.fileManager.currentFile()

@ -41,7 +41,7 @@ class Provider {
}
sendAsync (payload, callback) {
log.info('payload method is ', payload.method)
//log.info('payload method is ', payload.method)
const method = this.methods[payload.method]
if (this.options.logDetails) {

Loading…
Cancel
Save