Skip to content

Commit

Permalink
Fix linter errors in legacy adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 6, 2015
1 parent 04c881a commit 1ad2608
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions lib/adapters/legacy-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* @access private
*/
export default class LegacyAdater {
constructor(textEditor) { this.textEditor = textEditor }
constructor (textEditor) { this.textEditor = textEditor }

enableCache() { this.useCache = true }
enableCache () { this.useCache = true }

clearCache() {
clearCache () {
this.useCache = false
delete this.heightCache
delete this.scrollTopCache
delete this.scrollLeftCache
delete this.maxScrollTopCache
}

onDidChangeScrollTop(callback) {
onDidChangeScrollTop (callback) {
return this.textEditor.onDidChangeScrollTop(callback)
}

onDidChangeScrollLeft(callback) {
onDidChangeScrollLeft (callback) {
return this.textEditor.onDidChangeScrollLeft(callback)
}

getHeight() {
getHeight () {
if (this.useCache) {
if (!this.heightCache) {
this.heightCache = this.textEditor.getHeight()
Expand All @@ -34,8 +34,8 @@ export default class LegacyAdater {
return this.textEditor.getHeight()
}

getScrollTop() {
if(this.useCache) {
getScrollTop () {
if (this.useCache) {
if (!this.scrollTopCache) {
this.scrollTopCache = this.textEditor.getScrollTop()
}
Expand All @@ -44,12 +44,12 @@ export default class LegacyAdater {
return this.textEditor.getScrollTop()
}

setScrollTop(scrollTop) {
setScrollTop (scrollTop) {
return this.textEditor.setScrollTop(scrollTop)
}

getScrollLeft() {
if(this.useCache) {
getScrollLeft () {
if (this.useCache) {
if (!this.scrollLeftCache) {
this.scrollLeftCache = this.textEditor.getScrollLeft()
}
Expand All @@ -59,13 +59,17 @@ export default class LegacyAdater {
return this.textEditor.getScrollLeft()
}

getMaxScrollTop() {
if ((this.maxScrollTopCache != null) && this.useCache) { return this.maxScrollTopCache }
getMaxScrollTop () {
if (this.maxScrollTopCache != null && this.useCache) {
return this.maxScrollTopCache
}
var maxScrollTop = this.textEditor.displayBuffer.getMaxScrollTop()
var lineHeight = this.textEditor.getLineHeightInPixels()

if (this.scrollPastEnd) { maxScrollTop -= this.getHeight() - 3 * lineHeight }
if (this.useCache) { return this.maxScrollTopCache = maxScrollTop }
if (this.scrollPastEnd) {
maxScrollTop -= this.getHeight() - 3 * lineHeight
}
if (this.useCache) { this.maxScrollTopCache = maxScrollTop }
return maxScrollTop
}
}

0 comments on commit 1ad2608

Please sign in to comment.