How to Destroy set of markers in save event?


#1

I have the save event working fine also I have working version of creating marker like this way…

this.codeAtomMarker.createMarker(range)

code-atom-marker.js

export default class CodeAtomMarker {
  editor: null
  marker: null

  constructor(serializedState) {
    this.editor = atom.workspace.getActiveTextEditor()
  }

  // Returns an object that can be retrieved when package is activated
  serialize() {}

  // Tear down any state and detach
  destroy() {
    this.marker.remove();
  }

  createMarker(range) {
    this.marker = this.editor.markBufferRange(range)
    this.editor.decorateMarker(this.marker, {type: 'line-number', class: 'code-atom-marker'})
  }

  getElement() {
    return this.marker;
  }

}

Well my above code is not working. Atom not destroying my marker. How to modify my above code to support create marker on save event also delete all marker created when last save.


#2

I was doing it wrong. May be I can create a array to add set of markers. And delete exiting one upon next save and create new set of markers. That’s the idea.