Skip to content

Commit

Permalink
save and destroy currentLineBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 22, 2020
1 parent bf30d02 commit b5d7cd0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Editor {
showDecorations: boolean
showProviderName: boolean
ignoreTooltipInvocation: boolean
currentLineMarker: ?BufferMarker

constructor(textEditor: TextEditor) {
this.tooltip = null
Expand All @@ -34,6 +35,7 @@ class Editor {
this.textEditor = textEditor
this.subscriptions = new CompositeDisposable()
this.ignoreTooltipInvocation = false
this.currentLineMarker = null

this.subscriptions.add(this.emitter)
this.subscriptions.add(
Expand Down Expand Up @@ -127,7 +129,6 @@ class Editor {
listenForCurrentLine() {
this.subscriptions.add(
this.textEditor.observeCursors(cursor => {
let marker
let lastRange
let lastEmpty
const handlePositionChange = ({ start, end }) => {
Expand All @@ -145,16 +146,19 @@ class Editor {
linesRange.end.row--
}
if (lastRange && lastRange.isEqual(linesRange) && currentEmpty === lastEmpty) return
if (marker) marker.destroy()
if (this.currentLineMarker) {
this.currentLineMarker.destroy()
this.currentLineMarker = null
}
lastRange = linesRange
lastEmpty = currentEmpty

marker = this.textEditor.markScreenRange(linesRange, {
this.currentLineMarker = this.textEditor.markScreenRange(linesRange, {
invalidate: 'never',
})
const item = document.createElement('span')
item.className = `line-number cursor-line linter-cursor-line ${currentEmpty ? 'cursor-line-no-selection' : ''}`
gutter.decorateMarker(marker, {
gutter.decorateMarker(this.currentLineMarker, {
item,
class: 'linter-row',
})
Expand All @@ -178,7 +182,10 @@ class Editor {
)
subscriptions.add(
new Disposable(function() {
if (marker) marker.destroy()
if (this.currentLineMarker) {
this.currentLineMarker.destroy()
this.currentLineMarker = null
}
}),
)
this.subscriptions.add(subscriptions)
Expand Down

0 comments on commit b5d7cd0

Please sign in to comment.