Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/", "spec/fixtures"]
"ignorePatterns": ["dist/", "node_modules/", "spec/fixtures"],
"rules": {
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
12 changes: 10 additions & 2 deletions lib/adapters/legacy-adapter.js → lib/adapters/legacy-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict"

/**
* @access private
*/

export default class LegacyAdapter {
constructor(textEditor) {
this.textEditor = textEditor
Expand Down Expand Up @@ -33,8 +33,10 @@ export default class LegacyAdapter {
if (!this.heightCache) {
this.heightCache = this.textEditor.getHeight()
}

return this.heightCache
}

return this.textEditor.getHeight()
}

Expand All @@ -43,8 +45,10 @@ export default class LegacyAdapter {
if (!this.scrollTopCache) {
this.scrollTopCache = this.textEditor.getScrollTop()
}

return this.scrollTopCache
}

return this.textEditor.getScrollTop()
}

Expand All @@ -57,6 +61,7 @@ export default class LegacyAdapter {
if (!this.scrollLeftCache) {
this.scrollLeftCache = this.textEditor.getScrollLeft()
}

return this.scrollLeftCache
}

Expand All @@ -67,19 +72,22 @@ export default class LegacyAdapter {
if (this.maxScrollTopCache != null && this.useCache) {
return this.maxScrollTopCache
}

let maxScrollTop = this.textEditor.displayBuffer.getMaxScrollTop()
const lineHeight = this.textEditor.getLineHeightInPixels()

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

if (this.useCache) {
this.maxScrollTopCache = maxScrollTop
}

return maxScrollTop
}

editorDestroyed() {
return !this.textEditor || this.textEditor.isDestroyed()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict"

/**
* @access private
*/

export default class StableAdapter {
constructor(textEditor) {
this.textEditor = textEditor
Expand Down Expand Up @@ -38,8 +38,10 @@ export default class StableAdapter {
if (!this.heightCache) {
this.heightCache = this.textEditorElement.getHeight()
}

return this.heightCache
}

return this.textEditorElement.getHeight()
}

Expand All @@ -52,8 +54,10 @@ export default class StableAdapter {
if (!this.scrollTopCache) {
this.scrollTopCache = this.computeScrollTop()
}

return this.scrollTopCache
}

return this.computeScrollTop()
}

Expand Down Expand Up @@ -100,8 +104,10 @@ export default class StableAdapter {
if (!this.scrollLeftCache) {
this.scrollLeftCache = this.textEditorElement.getScrollLeft()
}

return this.scrollLeftCache
}

return this.textEditorElement.getScrollLeft()
}

Expand All @@ -115,6 +121,7 @@ export default class StableAdapter {
}

let maxScrollTop

if (this.textEditorElement.getMaxScrollTop) {
maxScrollTop = this.textEditorElement.getMaxScrollTop()

Expand Down Expand Up @@ -149,4 +156,4 @@ export default class StableAdapter {
!this.textEditorElement.parentNode
)
}
}
}
14 changes: 9 additions & 5 deletions lib/canvas-layer.js → lib/canvas-layer.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/** @babel */
"use strict"

/**
* @access private
*/

export default class CanvasLayer {
constructor() {
/**
* The onscreen canvas.
* @type {HTMLCanvasElement}
*/
this.canvas = document.createElement("canvas")

const desynchronized = false // TODO Electron 9 has color issues #786

/**
* The onscreen canvas context.
* @type {CanvasRenderingContext2D}
*/
this.context = this.canvas.getContext("2d", { desynchronized })
this.context = this.canvas.getContext("2d", {
desynchronized,
})
this.canvas.webkitImageSmoothingEnabled = false
this.context.imageSmoothingEnabled = false

Expand All @@ -28,12 +29,15 @@ export default class CanvasLayer {
* @access private
*/
this.offscreenCanvas = document.createElement("canvas")

/**
* The offscreen canvas context.
* @type {CanvasRenderingContext2D}
* @access private
*/
this.offscreenContext = this.offscreenCanvas.getContext("2d", { desynchronized })
this.offscreenContext = this.offscreenCanvas.getContext("2d", {
desynchronized,
})
this.offscreenCanvas.webkitImageSmoothingEnabled = false
this.offscreenContext.imageSmoothingEnabled = false
}
Expand Down Expand Up @@ -97,4 +101,4 @@ export default class CanvasLayer {
clearCanvas() {
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
}
}
}
Loading