Skip to content

Commit

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

constructor(textEditor: TextEditor) {
this.tooltip = null
Expand All @@ -36,6 +38,8 @@ class Editor {
this.subscriptions = new CompositeDisposable()
this.ignoreTooltipInvocation = false
this.currentLineMarker = null
this.lastRange = null
this.lastEmpty = null

this.subscriptions.add(this.emitter)
this.subscriptions.add(
Expand Down Expand Up @@ -129,8 +133,6 @@ class Editor {
listenForCurrentLine() {
this.subscriptions.add(
this.textEditor.observeCursors(cursor => {
let lastRange
let lastEmpty
const handlePositionChange = ({ start, end }) => {
const gutter = this.gutter
if (!gutter || this.subscriptions.disposed) return
Expand All @@ -145,13 +147,13 @@ class Editor {
if (start.row !== end.row && currentRange.end.column === 0) {
linesRange.end.row--
}
if (lastRange && lastRange.isEqual(linesRange) && currentEmpty === lastEmpty) return
if (this.lastRange && this.lastRange.isEqual(linesRange) && currentEmpty === this.lastEmpty) return
if (this.currentLineMarker) {
this.currentLineMarker.destroy()
this.currentLineMarker = null
}
lastRange = linesRange
lastEmpty = currentEmpty
this.lastRange = linesRange
this.lastEmpty = currentEmpty

this.currentLineMarker = this.textEditor.markScreenRange(linesRange, {
invalidate: 'never',
Expand Down

0 comments on commit e5f7387

Please sign in to comment.