From a8154c16f33aead4175f576a80a10f47cdbdf958 Mon Sep 17 00:00:00 2001 From: sidneys Date: Mon, 26 Aug 2019 12:20:50 +0200 Subject: [PATCH 1/4] chore(package.json): reference atom/superstring dependency directly from GitHub to incorporate the fixes required for Nodejs 12 compatibility. upgrades other dependencies to modern standards. --- package.json | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index d08f349ccd..0c5af1cde2 100644 --- a/package.json +++ b/package.json @@ -23,39 +23,39 @@ "atomTestRunner": "atom-jasmine2-test-runner", "license": "MIT", "devDependencies": { - "atom-jasmine2-test-runner": "^1.0.0", - "coffee-cache": "^0.2.0", - "coffee-script": "^1.10.0", - "coffeelint": "1.16.0", - "cpy-cli": "^1.0.1", - "dedent": "^0.6.0", + "atom-jasmine2-test-runner": "^2.99.1", + "coffee-cache": "^1.0.2", + "coffee-script": "^1.12.7", + "coffeelint": "2.1.0", + "cpy-cli": "^2.0.0", + "dedent": "^0.7.0", "donna": "^1.0.16", - "electron": "^1.7.11", - "jasmine": "^2.4.1", - "jasmine-core": "^2.4.1", + "electron": "^6.0.4", + "jasmine": "^3.4.0", + "jasmine-core": "^3.4.0", "joanna": "0.0.11", - "json-diff": "^0.3.1", - "random-seed": "^0.2.0", - "regression": "^1.2.1", - "rimraf": "~2.2.2", - "standard": "^10.0.3", - "tello": "^1.0.7", - "temp": "^0.8.3", - "yargs": "^6.5.0" + "json-diff": "^0.5.4", + "random-seed": "^0.3.0", + "regression": "^2.0.1", + "rimraf": "~3.0.0", + "standard": "^14.0.2", + "tello": "^1.2.0", + "temp": "^0.9.0", + "yargs": "^14.0.0" }, "dependencies": { "delegato": "^1.0.0", - "diff": "^2.2.1", - "emissary": "^1.0.0", - "event-kit": "^2.4.0", - "fs-admin": "^0.5.0", - "fs-plus": "^3.0.0", + "diff": "^4.0.1", + "emissary": "^1.3.3", + "event-kit": "^2.5.3", + "fs-admin": "^0.9.0", + "fs-plus": "^3.1.1", "grim": "^2.0.2", "mkdirp": "^0.5.1", "pathwatcher": "^8.1.0", "serializable": "^1.0.3", - "superstring": "2.4.0", - "underscore-plus": "^1.0.0" + "superstring": "git+https://git@github.com/atom/superstring.git#master", + "underscore-plus": "^1.7.0" }, "standard": { "env": { From 8093704eac62734af3eaf9fd9175c39eaeefbcd4 Mon Sep 17 00:00:00 2001 From: sidneys Date: Mon, 26 Aug 2019 13:43:41 +0200 Subject: [PATCH 2/4] fix(package.json): make build scripts actually use the referenced dependenciy modules (via npx) instead of referencing global namespace apps. also replaces the deprecated "prepublish" lifecycle phase with the newer "prepare" phase to ensure that the compilation is also done reliably when installing from Git oder locally (see github.com/npm/npm/issues/10074) --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0c5af1cde2..96419c3531 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "description": "A container for large mutable strings with annotated regions", "main": "./lib/text-buffer", "scripts": { - "prepublish": "npm run clean && npm run compile && npm run lint && npm run docs", + "prepare": "npm run clean && npm run compile && npm run lint && npm run docs", "docs": "node script/generate-docs", - "clean": "rimraf lib api.json", - "compile": "coffee --no-header --output lib --compile src && cpy src/*.js lib/", - "lint": "coffeelint -r src spec && standard src/*.js spec/*.js", + "clean": "npx rimraf lib api.json", + "compile": "npx coffee --no-header --output lib --compile src && npx cpy src/*.js lib/", + "lint": "npx coffeelint -r src spec && npx standard src/*.js spec/*.js", "test": "node script/test", "ci": "npm run compile && npm run lint && npm run test && npm run bench", "bench": "node benchmarks/index" @@ -24,10 +24,6 @@ "license": "MIT", "devDependencies": { "atom-jasmine2-test-runner": "^2.99.1", - "coffee-cache": "^1.0.2", - "coffee-script": "^1.12.7", - "coffeelint": "2.1.0", - "cpy-cli": "^2.0.0", "dedent": "^0.7.0", "donna": "^1.0.16", "electron": "^6.0.4", @@ -37,13 +33,15 @@ "json-diff": "^0.5.4", "random-seed": "^0.3.0", "regression": "^2.0.1", - "rimraf": "~3.0.0", - "standard": "^14.0.2", "tello": "^1.2.0", "temp": "^0.9.0", "yargs": "^14.0.0" }, "dependencies": { + "cpy-cli": "^2.0.0", + "coffee-cache": "^1.0.2", + "coffee-script": "^1.12.7", + "coffeelint": "2.1.0", "delegato": "^1.0.0", "diff": "^4.0.1", "emissary": "^1.3.3", @@ -53,7 +51,9 @@ "grim": "^2.0.2", "mkdirp": "^0.5.1", "pathwatcher": "^8.1.0", + "rimraf": "~3.0.0", "serializable": "^1.0.3", + "standard": "^14.0.2", "superstring": "git+https://git@github.com/atom/superstring.git#master", "underscore-plus": "^1.7.0" }, From 19010ee7ac56aa3f0271fea9d9e1807f57ae16c7 Mon Sep 17 00:00:00 2001 From: sidneys Date: Mon, 26 Aug 2019 13:12:21 +0200 Subject: [PATCH 3/4] chore(style): fixes linting issues suggested by the provided ruleset --- benchmarks/construction.js | 20 +- benchmarks/helpers.js | 10 +- benchmarks/mutation.js | 10 +- spec/display-layer-spec.js | 282 ++++++++++++++--------------- spec/fixtures/sample.js | 26 +-- spec/helpers/set.js | 12 +- spec/helpers/test-language-mode.js | 14 +- spec/support/runner/main.js | 2 +- spec/support/runner/renderer.js | 2 +- spec/text-buffer-io-spec.js | 34 ++-- src/display-layer.js | 100 +++++----- src/helpers.js | 8 +- src/null-language-mode.js | 2 +- src/screen-line-builder.js | 4 +- src/text-buffer.js | 60 +++--- 15 files changed, 293 insertions(+), 293 deletions(-) diff --git a/benchmarks/construction.js b/benchmarks/construction.js index 79c3670f81..bcf8b8c3c1 100644 --- a/benchmarks/construction.js +++ b/benchmarks/construction.js @@ -8,34 +8,34 @@ const SIZES_IN_KB = [ 10, 100, 1000, - 10000, + 10000 ] const bufferTimesInMS = [] const displayLayerTimesInMS = [] -for (let sizeInKB of SIZES_IN_KB) { - let text = helpers.getRandomText(sizeInKB) - let buffer = new TextBuffer({text}) +for (const sizeInKB of SIZES_IN_KB) { + const text = helpers.getRandomText(sizeInKB) + let buffer = new TextBuffer({ text }) - let t0 = Date.now() + const t0 = Date.now() for (let i = 0; i < TRIAL_COUNT; i++) { - buffer = new TextBuffer({text}) + buffer = new TextBuffer({ text }) buffer.getTextInRange([[0, 0], [50, 0]]) } - let t1 = Date.now() + const t1 = Date.now() for (let i = 0; i < TRIAL_COUNT; i++) { - let displayLayer = buffer.addDisplayLayer({}) + const displayLayer = buffer.addDisplayLayer({}) displayLayer.getScreenLines(0, 50) } - let t2 = Date.now() + const t2 = Date.now() bufferTimesInMS.push((t1 - t0) / TRIAL_COUNT) displayLayerTimesInMS.push((t2 - t1) / TRIAL_COUNT) } -function getMillisecondsPerMegabyte(timesInMS) { +function getMillisecondsPerMegabyte (timesInMS) { const series = timesInMS.map((time, i) => [SIZES_IN_KB[i], time * 1024]) const slownessRegression = regression('linear', series) return slownessRegression.equation[0] diff --git a/benchmarks/helpers.js b/benchmarks/helpers.js index 9bd206a5c9..e44b897beb 100644 --- a/benchmarks/helpers.js +++ b/benchmarks/helpers.js @@ -1,15 +1,15 @@ const WORDS = require('../spec/helpers/words') const Random = require('random-seed') const random = new Random(Date.now()) -const {Point, Range} = require('..') +const { Point, Range } = require('..') exports.getRandomText = function (sizeInKB) { const goalLength = Math.round(sizeInKB * 1024) let length = 0 - let lines = [] + const lines = [] let currentLine = '' - let lastLineStartIndex = 0 + // const lastLineStartIndex = 0 let goalLineLength = random(100) for (;;) { @@ -22,7 +22,7 @@ exports.getRandomText = function (sizeInKB) { goalLineLength = random(100) } - let choice = random(10) + const choice = random(10) if (choice < 2) { length++ currentLine += '\t' @@ -34,7 +34,7 @@ exports.getRandomText = function (sizeInKB) { length++ currentLine += ' ' } - word = WORDS[random(WORDS.length)] + const word = WORDS[random(WORDS.length)] length += word.length currentLine += word } diff --git a/benchmarks/mutation.js b/benchmarks/mutation.js index f9cbfe1766..dbd5380cf4 100644 --- a/benchmarks/mutation.js +++ b/benchmarks/mutation.js @@ -1,11 +1,11 @@ const helpers = require('./helpers') const TextBuffer = require('..') -let text = helpers.getRandomText(100) -let buffer = new TextBuffer({text}) -let displayLayer = buffer.addDisplayLayer({}) +const text = helpers.getRandomText(100) +const buffer = new TextBuffer({ text }) +// const displayLayer = buffer.addDisplayLayer({}) -let t0 = Date.now() +const t0 = Date.now() for (let i = 0; i < 1000; i++) { buffer.setTextInRange( @@ -14,7 +14,7 @@ for (let i = 0; i < 1000; i++) { ) } -let t1 = Date.now() +const t1 = Date.now() console.log('Mutation') console.log('------------') diff --git a/spec/display-layer-spec.js b/spec/display-layer-spec.js index 07ff4c7ed7..08c1fd89ea 100644 --- a/spec/display-layer-spec.js +++ b/spec/display-layer-spec.js @@ -3,10 +3,10 @@ const dedent = require('dedent') const TextBuffer = require('../src/text-buffer') const Point = require('../src/point') const Range = require('../src/range') -const {buildRandomLines, getRandomBufferRange} = require('./helpers/random') +const { buildRandomLines, getRandomBufferRange } = require('./helpers/random') const SAMPLE_TEXT = require('./helpers/sample-text') const TestLanguageMode = require('./helpers/test-language-mode') -const {Emitter} = require('event-kit') +const { Emitter } = require('event-kit') const EOL_INVISIBLE = '¬' const CR_INVISIBLE = '¤' @@ -55,21 +55,21 @@ describe('DisplayLayer', () => { describe('reset()', () => { it('updates the screen lines to reflect the new parameters', () => { - const buffer = new TextBuffer({text: 'abc def\nghi jkl\nmno pqr'}) + const buffer = new TextBuffer({ text: 'abc def\nghi jkl\nmno pqr' }) const displayLayer = buffer.addDisplayLayer({}) expect(displayLayer.translateScreenPosition(Point(1, 3))).toEqual(Point(1, 3)) - displayLayer.reset({softWrapColumn: 4}) + displayLayer.reset({ softWrapColumn: 4 }) expect(displayLayer.translateScreenPosition(Point(1, 3))).toEqual(Point(0, 7)) }) it('resets the rightmost screen position', () => { - const buffer = new TextBuffer({text: 'abc def\nghi jkl\nmnopqrst'}) - const displayLayer = buffer.addDisplayLayer({softWrapColumn: 5}) + const buffer = new TextBuffer({ text: 'abc def\nghi jkl\nmnopqrst' }) + const displayLayer = buffer.addDisplayLayer({ softWrapColumn: 5 }) expect(displayLayer.getApproximateRightmostScreenPosition()).toEqual(Point(0, 0)) expect(displayLayer.getRightmostScreenPosition()).toEqual(Point(4, 5)) - displayLayer.reset({softWrapColumn: 4}) + displayLayer.reset({ softWrapColumn: 4 }) expect(displayLayer.getApproximateRightmostScreenPosition()).toEqual(Point(0, 0)) expect(displayLayer.getRightmostScreenPosition()).toEqual(Point(0, 4)) }) @@ -77,7 +77,7 @@ describe('DisplayLayer', () => { describe('destroy', function () { it('does not throw exceptions when queried after destruction', function () { - const buffer = new TextBuffer({text: 'hi'}) + const buffer = new TextBuffer({ text: 'hi' }) const displayLayer = buffer.addDisplayLayer({}) @@ -102,18 +102,18 @@ describe('DisplayLayer', () => { expect(displayLayer.getText()).toBe(' a bc def g\nh i') expectTokenBoundaries(displayLayer, [ - {text: ' ', close: [], open: ['hard-tab leading-whitespace']}, - {text: 'a', close: ['hard-tab leading-whitespace'], open: []}, - {text: ' ', close: [], open: ['hard-tab']}, - {text: 'bc', close: ['hard-tab'], open: []}, - {text: ' ', close: [], open: ['hard-tab']}, - {text: 'def', close: ['hard-tab'], open: []}, - {text: ' ', close: [], open: ['hard-tab']}, - {text: 'g', close: ['hard-tab'], open: []}, - {text: 'h', close: [], open: []}, - {text: ' ', close: [], open: ['hard-tab']}, - {text: ' ', close: ['hard-tab'], open: ['hard-tab']}, - {text: 'i', close: ['hard-tab'], open: []} + { text: ' ', close: [], open: ['hard-tab leading-whitespace'] }, + { text: 'a', close: ['hard-tab leading-whitespace'], open: [] }, + { text: ' ', close: [], open: ['hard-tab'] }, + { text: 'bc', close: ['hard-tab'], open: [] }, + { text: ' ', close: [], open: ['hard-tab'] }, + { text: 'def', close: ['hard-tab'], open: [] }, + { text: ' ', close: [], open: ['hard-tab'] }, + { text: 'g', close: ['hard-tab'], open: [] }, + { text: 'h', close: [], open: [] }, + { text: ' ', close: [], open: ['hard-tab'] }, + { text: ' ', close: ['hard-tab'], open: ['hard-tab'] }, + { text: 'i', close: ['hard-tab'], open: [] } ]) expectPositionTranslations(displayLayer, [ @@ -507,7 +507,7 @@ describe('DisplayLayer', () => { foldsMarkerLayer.markRange([[2, 2], [3, 1]]) foldsMarkerLayer.markRange([[3, 2], [4, 1]]) foldsMarkerLayer.markRange([[4, 2], [5, 1]]) - const displayLayer = buffer.addDisplayLayer({foldsMarkerLayer}) + const displayLayer = buffer.addDisplayLayer({ foldsMarkerLayer }) expect(displayLayer.indexedBufferRowCount).toBe(0) displayLayer.foldBufferRange([[0, 2], [1, 1]]) @@ -523,7 +523,7 @@ describe('DisplayLayer', () => { foldsMarkerLayer.markRange([[2, 1], [3, 2]]) foldsMarkerLayer.markRange([[3, 1], [4, 2]]) foldsMarkerLayer.markRange([[4, 2], [5, 1]]) - const displayLayer = buffer.addDisplayLayer({foldsMarkerLayer}) + const displayLayer = buffer.addDisplayLayer({ foldsMarkerLayer }) expect(displayLayer.indexedBufferRowCount).toBe(0) displayLayer.foldBufferRange([[0, 2], [1, 1]]) @@ -534,7 +534,7 @@ describe('DisplayLayer', () => { const now = Date.now() for (let i = 0; i < 100; i++) { - let seed = now + i + const seed = now + i try { const random = new Random(seed) @@ -550,7 +550,7 @@ describe('DisplayLayer', () => { foldsMarkerLayer.markRange(getRandomBufferRange(random, buffer)) } - const displayLayer = buffer.addDisplayLayer({foldsMarkerLayer}) + const displayLayer = buffer.addDisplayLayer({ foldsMarkerLayer }) const randomRange = getRandomBufferRange(random, buffer) @@ -578,7 +578,7 @@ describe('DisplayLayer', () => { }) const displayLayer = buffer.addDisplayLayer({ tabLength: 4, - invisibles: {eol: '¬'}, + invisibles: { eol: '¬' }, softWrapColumn: 10 }) displayLayer.foldBufferRange([[0, 16], [1, 4]]) @@ -683,14 +683,14 @@ describe('DisplayLayer', () => { it('takes into account character ratios when determining the wrap boundary', () => { const ratiosByCharacter = { - 'ㅅ': 1.3, - 'ㅘ': 1.3, - 'カ': 0.5, - 'ユ': 0.5, - 'あ': 2, - '繁': 2, - '體': 2, - '字': 2, + ㅅ: 1.3, + ㅘ: 1.3, + カ: 0.5, + ユ: 0.5, + あ: 2, + 繁: 2, + 體: 2, + 字: 2, ' ': 4 } @@ -919,7 +919,7 @@ describe('DisplayLayer', () => { it('translates points correctly on soft-wrapped lines', () => { { - const buffer = new TextBuffer({text: ' abc defgh'}) + const buffer = new TextBuffer({ text: ' abc defgh' }) const displayLayer = buffer.addDisplayLayer({ softWrapColumn: 8, softWrapHangingIndent: 2 @@ -959,18 +959,18 @@ describe('DisplayLayer', () => { { // Translating in the middle of an atomic soft tab that has been soft-wrapped. - const buffer = new TextBuffer({text: ' '}) - const displayLayer = buffer.addDisplayLayer({tabLength: 2, softWrapColumn: 3}) + const buffer = new TextBuffer({ text: ' ' }) + const displayLayer = buffer.addDisplayLayer({ tabLength: 2, softWrapColumn: 3 }) expect(displayLayer.getText()).toBe(' \n ') - expect(displayLayer.translateBufferPosition([0, 3], {clipDirection: 'backward'})).toEqual([0, 2]) - expect(displayLayer.translateBufferPosition([0, 3], {clipDirection: 'closest'})).toEqual([0, 2]) - expect(displayLayer.translateBufferPosition([0, 3], {clipDirection: 'forward'})).toEqual([1, 1]) + expect(displayLayer.translateBufferPosition([0, 3], { clipDirection: 'backward' })).toEqual([0, 2]) + expect(displayLayer.translateBufferPosition([0, 3], { clipDirection: 'closest' })).toEqual([0, 2]) + expect(displayLayer.translateBufferPosition([0, 3], { clipDirection: 'forward' })).toEqual([1, 1]) - expect(displayLayer.translateScreenPosition([1, 0], {clipDirection: 'backward'})).toEqual([0, 2]) - expect(displayLayer.translateScreenPosition([1, 0], {clipDirection: 'closest'})).toEqual([0, 2]) - expect(displayLayer.translateScreenPosition([1, 0], {clipDirection: 'forward'})).toEqual([0, 4]) + expect(displayLayer.translateScreenPosition([1, 0], { clipDirection: 'backward' })).toEqual([0, 2]) + expect(displayLayer.translateScreenPosition([1, 0], { clipDirection: 'closest' })).toEqual([0, 2]) + expect(displayLayer.translateScreenPosition([1, 0], { clipDirection: 'forward' })).toEqual([0, 4]) } }) @@ -1074,7 +1074,7 @@ describe('DisplayLayer', () => { text: 'abcdef\nghijkl' }) - let displayLayer = buffer.addDisplayLayer({ + const displayLayer = buffer.addDisplayLayer({ softWrapColumn: 4 }) displayLayer.foldBufferRange([[0, 3], [1, 3]]) @@ -1086,7 +1086,7 @@ describe('DisplayLayer', () => { text: ' abcdef\nghijk\nlmnop' }) - let displayLayer = buffer.addDisplayLayer({ + const displayLayer = buffer.addDisplayLayer({ softWrapColumn: 6 }) displayLayer.foldBufferRange([[0, 5], [1, 1]]) @@ -1665,48 +1665,48 @@ describe('DisplayLayer', () => { ) expectTokenBoundaries(displayLayer, [ - {text: '¬', close: [], open: ['invisible-character eol indent-guide']}, - {text: ' ', close: ['invisible-character eol indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol indent-guide']}, - {text: ' ', close: ['invisible-character eol indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: ' ', close: [], open: ['leading-whitespace indent-guide']}, - {text: ' ', close: ['leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide']}, - {text: ' ', close: ['leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide']}, - {text: 'a', close: ['leading-whitespace indent-guide'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol']}, - {text: '', close: ['invisible-character eol'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol indent-guide']}, - {text: ' ', close: ['invisible-character eol indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: ' ', close: [], open: ['hard-tab leading-whitespace indent-guide']}, - {text: ' ', close: ['hard-tab leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide']}, - {text: ' ', close: ['leading-whitespace indent-guide'], open: ['hard-tab leading-whitespace']}, - {text: ' ', close: ['hard-tab leading-whitespace'], open: ['leading-whitespace indent-guide']}, - {text: 'b', close: ['leading-whitespace indent-guide'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol']}, - {text: '', close: ['invisible-character eol'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol indent-guide']}, - {text: ' ', close: ['invisible-character eol indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: '¬', close: [], open: ['invisible-character eol indent-guide']}, - {text: ' ', close: ['invisible-character eol indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: ' ', close: ['indent-guide'], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []} + { text: '¬', close: [], open: ['invisible-character eol indent-guide'] }, + { text: ' ', close: ['invisible-character eol indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol indent-guide'] }, + { text: ' ', close: ['invisible-character eol indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: ' ', close: [], open: ['leading-whitespace indent-guide'] }, + { text: ' ', close: ['leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide'] }, + { text: ' ', close: ['leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide'] }, + { text: 'a', close: ['leading-whitespace indent-guide'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol'] }, + { text: '', close: ['invisible-character eol'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol indent-guide'] }, + { text: ' ', close: ['invisible-character eol indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: ' ', close: [], open: ['hard-tab leading-whitespace indent-guide'] }, + { text: ' ', close: ['hard-tab leading-whitespace indent-guide'], open: ['leading-whitespace indent-guide'] }, + { text: ' ', close: ['leading-whitespace indent-guide'], open: ['hard-tab leading-whitespace'] }, + { text: ' ', close: ['hard-tab leading-whitespace'], open: ['leading-whitespace indent-guide'] }, + { text: 'b', close: ['leading-whitespace indent-guide'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol'] }, + { text: '', close: ['invisible-character eol'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol indent-guide'] }, + { text: ' ', close: ['invisible-character eol indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: '¬', close: [], open: ['invisible-character eol indent-guide'] }, + { text: ' ', close: ['invisible-character eol indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: ' ', close: ['indent-guide'], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] } ]) expect(displayLayer.clipScreenPosition([0, 0], { @@ -1787,15 +1787,15 @@ describe('DisplayLayer', () => { expect(JSON.stringify(displayLayer.getText())).toBe(JSON.stringify('a\n\nb\n c\n \n ')) expectTokenBoundaries(displayLayer, [ - {text: 'a', close: [], open: []}, - {text: '', close: [], open: []}, - {text: 'b', close: [], open: []}, - {text: ' ', close: [], open: ['leading-whitespace indent-guide']}, - {text: 'c', close: ['leading-whitespace indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []}, - {text: ' ', close: [], open: ['indent-guide']}, - {text: '', close: ['indent-guide'], open: []} + { text: 'a', close: [], open: [] }, + { text: '', close: [], open: [] }, + { text: 'b', close: [], open: [] }, + { text: ' ', close: [], open: ['leading-whitespace indent-guide'] }, + { text: 'c', close: ['leading-whitespace indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] }, + { text: ' ', close: [], open: ['indent-guide'] }, + { text: '', close: ['indent-guide'], open: [] } ]) }) }) @@ -1817,35 +1817,35 @@ describe('DisplayLayer', () => { ])) expectTokenBoundaries(displayLayer, [ - {text: 'a', close: [], open: []}, - {text: 'b', close: [], open: ['aa']}, - {text: 'c', close: [], open: ['ab']}, - {text: 'd', close: [], open: ['ac']}, - {text: 'e', close: ['ac', 'ab', 'aa'], open: ['ab', 'ac']}, - {text: '', close: ['ac', 'ab'], open: []}, - {text: 'fg', close: [], open: ['ab', 'ac']}, - {text: 'h', close: ['ac', 'ab'], open: []}, - {text: 'ij', close: [], open: ['ad']}, - {text: '', close: ['ad'], open: []}, - {text: 'klm', close: [], open: []}, - {text: 'no', close: [], open: ['ae']}, - {text: '', close: ['ae'], open: []} + { text: 'a', close: [], open: [] }, + { text: 'b', close: [], open: ['aa'] }, + { text: 'c', close: [], open: ['ab'] }, + { text: 'd', close: [], open: ['ac'] }, + { text: 'e', close: ['ac', 'ab', 'aa'], open: ['ab', 'ac'] }, + { text: '', close: ['ac', 'ab'], open: [] }, + { text: 'fg', close: [], open: ['ab', 'ac'] }, + { text: 'h', close: ['ac', 'ab'], open: [] }, + { text: 'ij', close: [], open: ['ad'] }, + { text: '', close: ['ad'], open: [] }, + { text: 'klm', close: [], open: [] }, + { text: 'no', close: [], open: ['ae'] }, + { text: '', close: ['ae'], open: [] } ]) }) it('includes indent guides and EOL characters within containing decoration tags', function () { const buffer = new TextBuffer({ text: [ - '', // empty line with no indent guide + '', // empty line with no indent guide '1', ' ', // whitespace-only line - '' // empty line with an indent guide + '' // empty line with an indent guide ].join('\n') }) const displayLayer = buffer.addDisplayLayer({ showIndentGuides: true, - invisibles: {eol: '¬'} + invisibles: { eol: '¬' } }) expect(displayLayer.getText().split('\n')).toEqual([ @@ -1860,16 +1860,16 @@ describe('DisplayLayer', () => { ])) expectTokenBoundaries(displayLayer, [ - {text: '¬', close: [], open: ['a', 'invisible-character eol indent-guide']}, - {text: '', close: ['invisible-character eol indent-guide', 'a'], open: []}, - {text: '1', close: [], open: ['a']}, - {text: '¬', close: [], open: ['invisible-character eol']}, - {text: '', close: ['invisible-character eol', 'a'], open: []}, - {text: ' ', close: [], open: ['a', 'trailing-whitespace indent-guide']}, - {text: '¬', close: ['trailing-whitespace indent-guide'], open: ['invisible-character eol']}, - {text: '', close: ['invisible-character eol', 'a'], open: []}, - {text: ' ', close: [], open: ['a', 'indent-guide']}, - {text: '', close: ['indent-guide', 'a'], open: []} + { text: '¬', close: [], open: ['a', 'invisible-character eol indent-guide'] }, + { text: '', close: ['invisible-character eol indent-guide', 'a'], open: [] }, + { text: '1', close: [], open: ['a'] }, + { text: '¬', close: [], open: ['invisible-character eol'] }, + { text: '', close: ['invisible-character eol', 'a'], open: [] }, + { text: ' ', close: [], open: ['a', 'trailing-whitespace indent-guide'] }, + { text: '¬', close: ['trailing-whitespace indent-guide'], open: ['invisible-character eol'] }, + { text: '', close: ['invisible-character eol', 'a'], open: [] }, + { text: ' ', close: [], open: ['a', 'indent-guide'] }, + { text: '', close: ['indent-guide', 'a'], open: [] } ]) }) @@ -1976,7 +1976,7 @@ describe('DisplayLayer', () => { }, onDidChangeHighlighting () { - return {dispose () {}} + return { dispose () {} } } }) @@ -2215,8 +2215,8 @@ describe('DisplayLayer', () => { }) it('clips to the closest tab stop when translating a screen position that is in the middle of a hard tab', () => { - const buffer = new TextBuffer({text: '\t\t\t'}) - const displayLayer = buffer.addDisplayLayer({tabLength: 4}) + const buffer = new TextBuffer({ text: '\t\t\t' }) + const displayLayer = buffer.addDisplayLayer({ tabLength: 4 }) expect(displayLayer.translateScreenPosition([0, 0])).toEqual([0, 0]) expect(displayLayer.translateScreenPosition([0, 1])).toEqual([0, 0]) @@ -2238,7 +2238,7 @@ describe('DisplayLayer', () => { text: 'abc\ndef\nghi\njkl\nmno' }) - const displayLayer = buffer.addDisplayLayer({tabLength: 4}) + const displayLayer = buffer.addDisplayLayer({ tabLength: 4 }) const events = [] displayLayer.onDidChange((changes) => events.push(...changes)) @@ -2288,7 +2288,7 @@ describe('DisplayLayer', () => { text: 'abc\ndef\nghi\njkl\nmno' }) - const displayLayer = buffer.addDisplayLayer({tabLength: 4}) + const displayLayer = buffer.addDisplayLayer({ tabLength: 4 }) const events = [] displayLayer.onDidChange((changes) => events.push(changes)) @@ -2446,8 +2446,8 @@ describe('DisplayLayer', () => { describe('.bufferRowsForScreenRows(startRow, endRow)', () => { it('returns an array containing the buffer rows for the given screen row range', () => { - const buffer = new TextBuffer({text: 'abcde\nfghij\nklmno\npqrst\nuvwxyz'}) - const displayLayer = buffer.addDisplayLayer({softWrapColumn: 4}) + const buffer = new TextBuffer({ text: 'abcde\nfghij\nklmno\npqrst\nuvwxyz' }) + const displayLayer = buffer.addDisplayLayer({ softWrapColumn: 4 }) const fold1 = displayLayer.foldBufferRange([[0, 1], [1, 1]]) // eslint-disable-line no-unused-vars const fold2 = displayLayer.foldBufferRange([[2, 2], [3, 2]]) const fold3 = displayLayer.foldBufferRange([[3, 3], [3, 4]]) // eslint-disable-line no-unused-vars @@ -2481,7 +2481,7 @@ describe('DisplayLayer', () => { const now = Date.now() for (let i = 0; i < 200; i++) { - let seed = now + i + const seed = now + i try { const random = new Random(seed) @@ -2549,7 +2549,7 @@ describe('DisplayLayer', () => { performRandomChange(random, displayLayer) } else { const softWrapColumn = random(2) ? random.intBetween(5, 80) : null - displayLayer.reset({softWrapColumn}) + displayLayer.reset({ softWrapColumn }) } if (!hasComputedAllScreenRows(displayLayer)) { @@ -2676,7 +2676,7 @@ function verifyLineLengths (displayLayer) { const rowCount = getComputedScreenLineCount(displayLayer) const screenLines = displayLayer.getScreenLines(0, rowCount) for (let row = 0; row < rowCount; row++) { - let text = screenLines[row].lineText.replace(LINE_ENDING_INVISIBLES_REGEXP, '') + const text = screenLines[row].lineText.replace(LINE_ENDING_INVISIBLES_REGEXP, '') expect(displayLayer.lineLengthForScreenRow(row)).toBe(text.length) } } @@ -2685,7 +2685,7 @@ function verifyTokenConsistency (displayLayer) { const containingTags = [] for (const tokens of getTokenBoundaries(displayLayer, 0, getComputedScreenLineCount(displayLayer))) { - for (const {closeTags, openTags} of tokens) { + for (const { closeTags, openTags } of tokens) { for (const tag of closeTags) { const mostRecentOpenTag = containingTags.pop() expect(mostRecentOpenTag).toBe(tag) @@ -2781,11 +2781,11 @@ function expectPositionTranslations (displayLayer, tranlations) { } else { const bufferPosition = bufferPositions expect(displayLayer.translateScreenPosition(screenPosition)).toEqual(bufferPosition, `translateScreenPosition(Point${screenPosition})`) - expect(displayLayer.translateScreenPosition(screenPosition, {clipDirection: 'forward'})).toEqual(bufferPosition, `translateScreenPosition(Point${screenPosition}, {clipDirection: 'forward'})`) - expect(displayLayer.translateScreenPosition(screenPosition, {clipDirection: 'backward'})).toEqual(bufferPosition, `translateScreenPosition(Point${screenPosition}, {clipDirection: 'backward'})`) + expect(displayLayer.translateScreenPosition(screenPosition, { clipDirection: 'forward' })).toEqual(bufferPosition, `translateScreenPosition(Point${screenPosition}, {clipDirection: 'forward'})`) + expect(displayLayer.translateScreenPosition(screenPosition, { clipDirection: 'backward' })).toEqual(bufferPosition, `translateScreenPosition(Point${screenPosition}, {clipDirection: 'backward'})`) expect(displayLayer.translateBufferPosition(bufferPosition)).toEqual(screenPosition, `translateScreenPosition(Point${bufferPosition})`) - expect(displayLayer.translateBufferPosition(bufferPosition, {clipDirection: 'forward'})).toEqual(screenPosition, `translateScreenPosition(Point${bufferPosition}, {clipDirection: 'forward'})`) - expect(displayLayer.translateBufferPosition(bufferPosition, {clipDirection: 'backward'})).toEqual(screenPosition, `translateScreenPosition(Point${bufferPosition}, {clipDirection: 'backward'})`) + expect(displayLayer.translateBufferPosition(bufferPosition, { clipDirection: 'forward' })).toEqual(screenPosition, `translateScreenPosition(Point${bufferPosition}, {clipDirection: 'forward'})`) + expect(displayLayer.translateBufferPosition(bufferPosition, { clipDirection: 'backward' })).toEqual(screenPosition, `translateScreenPosition(Point${bufferPosition}, {clipDirection: 'backward'})`) } } } @@ -2801,7 +2801,7 @@ function expectTokenBoundaries (displayLayer, expectedTokens) { throw new Error('There are more tokens than expected.') } - const {text, open, close} = expectedTokens.shift() + const { text, open, close } = expectedTokens.shift() expect(token.text).toEqual( text, @@ -2829,7 +2829,7 @@ const getTokens = function (displayLayer, startRow = 0, endRow = displayLayer.ge for (const line of getTokenBoundaries(displayLayer, startRow, endRow)) { const tokenLine = [] - for (const {closeTags, openTags, text} of line) { + for (const { closeTags, openTags, text } of line) { for (let i = 0; i < closeTags.length; i++) { containingTags.pop() } @@ -2851,7 +2851,7 @@ const getTokens = function (displayLayer, startRow = 0, endRow = displayLayer.ge function getTokenBoundaries (displayLayer, startRow = 0, endRow = displayLayer.getScreenLineCount()) { const tokenLines = [] - for (const {lineText, tags} of displayLayer.getScreenLines(startRow, endRow)) { + for (const { lineText, tags } of displayLayer.getScreenLines(startRow, endRow)) { const tokens = [] let startIndex = 0 let closeTags = [] @@ -2890,7 +2890,7 @@ function getTokenBoundaries (displayLayer, startRow = 0, endRow = displayLayer.g } function updateTokenLines (tokenLines, displayLayer, changes) { - for (const {oldRange, newRange} of changes || []) { + for (const { oldRange, newRange } of changes || []) { const newTokenLines = getTokens(displayLayer, newRange.start.row, newRange.end.row) tokenLines.splice(newRange.start.row, oldRange.end.row - oldRange.start.row, ...newTokenLines) } @@ -2900,7 +2900,7 @@ function logTokens (displayLayer) { // eslint-disable-line let s = 'expectTokenBoundaries(displayLayer, [\n' for (const tokens of getTokenBoundaries(displayLayer)) { - for (const {text, closeTags, openTags} of tokens) { + for (const { text, closeTags, openTags } of tokens) { s += (" {text: '" + (text) + "', close: " + (JSON.stringify(closeTags)) + ', open: ' + (JSON.stringify(openTags)) + '},\n') } } diff --git a/spec/fixtures/sample.js b/spec/fixtures/sample.js index fb33b0b43b..05ded9439c 100644 --- a/spec/fixtures/sample.js +++ b/spec/fixtures/sample.js @@ -1,13 +1,13 @@ -var quicksort = function () { - var sort = function(items) { - if (items.length <= 1) return items; - var pivot = items.shift(), current, left = [], right = []; - while(items.length > 0) { - current = items.shift(); - current < pivot ? left.push(current) : right.push(current); - } - return sort(left).concat(pivot).concat(sort(right)); - }; - - return sort(Array.apply(this, arguments)); -}; \ No newline at end of file +// var quicksort = function () { +// var sort = function (items) { +// if (items.length <= 1) return items +// var pivot = items.shift(); var current; var left = []; var right = [] +// while (items.length > 0) { +// current = items.shift() +// current < pivot ? left.push(current) : right.push(current) +// } +// return sort(left).concat(pivot).concat(sort(right)) +// } +// +// return sort(Array.apply(this, arguments)) +// } diff --git a/spec/helpers/set.js b/spec/helpers/set.js index c024bd1df8..e45a95b770 100644 --- a/spec/helpers/set.js +++ b/spec/helpers/set.js @@ -24,9 +24,9 @@ Set.prototype.jasmineToString = function () { // eslint-disable-line no-extend-n return result + '}' } -let toEqualSet = (expectedItems, customMessage) => { +const toEqualSet = (expectedItems, customMessage) => { let pass = true - let expectedSet = new Set(expectedItems) + const expectedSet = new Set(expectedItems) if (customMessage == null) { customMessage = '' } @@ -52,12 +52,12 @@ let toEqualSet = (expectedItems, customMessage) => { return pass } -let formatSet = (set) => { +const formatSet = (set) => { return '(' + (setToArray(set).join(' ')) + ')' } -let setToArray = (set) => { - let items = [] +const setToArray = (set) => { + const items = [] set.forEach((item) => { return items.push(item) }) @@ -76,4 +76,4 @@ let setToArray = (set) => { // }) // } -module.exports = {toEqualSet, formatSet} +module.exports = { toEqualSet, formatSet } diff --git a/spec/helpers/test-language-mode.js b/spec/helpers/test-language-mode.js index c229524054..cdbc8ce92f 100644 --- a/spec/helpers/test-language-mode.js +++ b/spec/helpers/test-language-mode.js @@ -1,8 +1,8 @@ -const {MarkerIndex} = require('superstring') -const {Emitter} = require('event-kit') +const { MarkerIndex } = require('superstring') +const { Emitter } = require('event-kit') const Point = require('../../src/point') const Range = require('../../src/range') -const {MAX_BUILT_IN_SCOPE_ID} = require('../../src/constants') +const { MAX_BUILT_IN_SCOPE_ID } = require('../../src/constants') module.exports = class TestLanguageMode { @@ -24,7 +24,7 @@ class TestLanguageMode { }) } - for (let value of decorations) { + for (const value of decorations) { const className = value[0] const [rangeStart, rangeEnd] = Array.from(value[1]) const markerId = this.getNextMarkerId() @@ -41,9 +41,9 @@ class TestLanguageMode { return this.emitter.on('did-change-highlighting', fn) } - bufferDidChange ({oldRange, newRange}) { + bufferDidChange ({ oldRange, newRange }) { this.invalidatedRanges.push(Range.fromObject(newRange)) - const {inside, overlap} = this.markerIndex.splice(oldRange.start, oldRange.getExtent(), newRange.getExtent()) + const { inside, overlap } = this.markerIndex.splice(oldRange.start, oldRange.getExtent(), newRange.getExtent()) overlap.forEach((id) => this.invalidatedRanges.push(Range.fromObject(this.markerIndex.getRange(id)))) inside.forEach((id) => this.invalidatedRanges.push(Range.fromObject(this.markerIndex.getRange(id)))) @@ -113,7 +113,7 @@ class TestHighlightIterator { } seek (position, endBufferRow) { - const {containingStart, boundaries} = this.layer.markerIndex.findBoundariesAfter(position, Number.MAX_SAFE_INTEGER) + const { containingStart, boundaries } = this.layer.markerIndex.findBoundariesAfter(position, Number.MAX_SAFE_INTEGER) this.boundaries = boundaries this.boundaryIndex = 0 this.endBufferRow = endBufferRow diff --git a/spec/support/runner/main.js b/spec/support/runner/main.js index fdce32183b..6316a0c0b6 100644 --- a/spec/support/runner/main.js +++ b/spec/support/runner/main.js @@ -10,7 +10,7 @@ let mainWindow function createWindow () { // Create the browser window. - mainWindow = new BrowserWindow({width: 800, height: 600}) + mainWindow = new BrowserWindow({ width: 800, height: 600 }) // and load the index.html of the app. mainWindow.loadURL(`file://${__dirname}/index.html`) diff --git a/spec/support/runner/renderer.js b/spec/support/runner/renderer.js index e6462f418d..9d2bbc52dc 100644 --- a/spec/support/runner/renderer.js +++ b/spec/support/runner/renderer.js @@ -1,4 +1,4 @@ -const {remote} = require('electron') +const { remote } = require('electron') const path = require('path') const Command = require('jasmine/lib/command.js') diff --git a/spec/text-buffer-io-spec.js b/spec/text-buffer-io-spec.js index 0816a58d4d..fca57671e9 100644 --- a/spec/text-buffer-io-spec.js +++ b/spec/text-buffer-io-spec.js @@ -1,12 +1,12 @@ const fs = require('fs-plus') const path = require('path') -const {Writable, Transform} = require('stream') +const { Writable, Transform } = require('stream') const temp = require('temp') -const {Disposable} = require('event-kit') +const { Disposable } = require('event-kit') const Point = require('../src/point') const Range = require('../src/range') const TextBuffer = require('../src/text-buffer') -const {TextBuffer: NativeTextBuffer} = require('superstring') +const { TextBuffer: NativeTextBuffer } = require('superstring') const fsAdmin = require('fs-admin') const pathwatcher = require('pathwatcher') @@ -64,7 +64,7 @@ describe('TextBuffer IO', () => { it('optionally rejects with an ENOENT if there is no file at the given path', async done => { const filePath = 'does-not-exist.txt' try { - await TextBuffer.load(filePath, {mustExist: true}) + await TextBuffer.load(filePath, { mustExist: true }) } catch (error) { expect(error.code).toBe('ENOENT') done() @@ -111,7 +111,7 @@ describe('TextBuffer IO', () => { it('optionally throws ENOENT if there is no file at the given path', () => { try { - TextBuffer.loadSync('/does-not-exist.txt', {mustExist: true}) + TextBuffer.loadSync('/does-not-exist.txt', { mustExist: true }) expect('Did not fail with mustExist: true').toBeUndefined() } catch (e) { expect(e.code).toBe('ENOENT') @@ -161,14 +161,14 @@ describe('TextBuffer IO', () => { displayLayer.onDidChange((event) => events.push(['display-layer', event])) buffer.setLanguageMode({ - bufferDidChange ({oldRange, newRange, oldText, newText}) { - events.push(['decoration-layer', {oldRange, newRange, oldText, newText}]) + bufferDidChange ({ oldRange, newRange, oldText, newText }) { + events.push(['decoration-layer', { oldRange, newRange, oldText, newText }]) }, bufferDidFinishTransaction () {}, onDidChangeHighlighting () { - return {dispose () {}} + return { dispose () {} } } }) @@ -243,7 +243,7 @@ describe('TextBuffer IO', () => { } { - const subscription = buffer.onDidStopChanging(({changes}) => { + const subscription = buffer.onDidStopChanging(({ changes }) => { subscription.dispose() expect(changes.length).toBe(1) @@ -354,8 +354,8 @@ describe('TextBuffer IO', () => { await buffer.save() const path = buffer.getPath() expect(events).toEqual([ - ['will-save', {path}, ''], - ['did-save', {path}, 'Buffer contents'] + ['will-save', { path }, ''], + ['did-save', { path }, 'Buffer contents'] ]) done() }) @@ -455,7 +455,7 @@ describe('TextBuffer IO', () => { spyOn(NativeTextBuffer.prototype, 'save').and.callFake(function (destination, encoding) { if (destination === filePath) { - return Promise.reject(Object.assign(new Error('Permission denied'), {code: 'EACCES'})) + return Promise.reject(Object.assign(new Error('Permission denied'), { code: 'EACCES' })) } return save.call(this, destination, encoding) @@ -633,7 +633,7 @@ describe('TextBuffer IO', () => { }) it('returns true for a non-empty buffer with no path', () => { - buffer2 = new TextBuffer({text: 'something'}) + buffer2 = new TextBuffer({ text: 'something' }) expect(buffer2.isModified()).toBeTruthy() buffer2.append('a') @@ -652,7 +652,7 @@ describe('TextBuffer IO', () => { buffer = await TextBuffer.load(filePath) buffer.append('ghi\n') - const markerLayer = buffer.addMarkerLayer({persistent: true}) + const markerLayer = buffer.addMarkerLayer({ persistent: true }) const marker = markerLayer.markRange(Range(Point(1, 2), Point(2, 1))) buffer2 = await TextBuffer.deserialize(buffer.serialize()) @@ -689,7 +689,7 @@ describe('TextBuffer IO', () => { it('serializes the encoding', async done => { const filePath = path.join(__dirname, 'fixtures', 'win1251.txt') - buffer = await TextBuffer.load(filePath, {encoding: 'WINDOWS-1251'}) + buffer = await TextBuffer.load(filePath, { encoding: 'WINDOWS-1251' }) buffer2 = await TextBuffer.deserialize(buffer.serialize()) expect(buffer2.getEncoding()).toBe('WINDOWS-1251') expect(buffer2.getText()).toBe('тест 1234 абвгдеёжз') @@ -700,7 +700,7 @@ describe('TextBuffer IO', () => { describe('encoding support', () => { it('allows the encoding to be set on creation', async done => { const filePath = path.join(__dirname, 'fixtures', 'win1251.txt') - buffer = await TextBuffer.load(filePath, {encoding: 'WINDOWS-1251'}) + buffer = await TextBuffer.load(filePath, { encoding: 'WINDOWS-1251' }) expect(buffer.getEncoding()).toBe('WINDOWS-1251') expect(buffer.getText()).toBe('тест 1234 абвгдеёжз') done() @@ -1007,7 +1007,7 @@ describe('TextBuffer IO', () => { beforeEach(async done => { filePath = path.join(temp.mkdirSync(), 'file-to-delete') fs.writeFileSync(filePath, 'delete me') - buffer = await TextBuffer.load(filePath, {shouldDestroyOnFileDelete: () => closeDeletedFileTabs}) + buffer = await TextBuffer.load(filePath, { shouldDestroyOnFileDelete: () => closeDeletedFileTabs }) filePath = buffer.getPath() // symlinks may have been converted done() }) diff --git a/src/display-layer.js b/src/display-layer.js index 87bc774f69..2ecd395167 100644 --- a/src/display-layer.js +++ b/src/display-layer.js @@ -1,13 +1,13 @@ -const {Patch} = require('superstring') -const {Emitter} = require('event-kit') +const { Patch } = require('superstring') +const { Emitter } = require('event-kit') const Point = require('./point') const Range = require('./range') const DisplayMarkerLayer = require('./display-marker-layer') -const {traverse, traversal, compare, max, isEqual} = require('./point-helpers') +const { traverse, traversal, compare, max, isEqual } = require('./point-helpers') const isCharacterPair = require('./is-character-pair') const ScreenLineBuilder = require('./screen-line-builder') -const {spliceArray} = require('./helpers') -const {MAX_BUILT_IN_SCOPE_ID} = require('./constants') +const { spliceArray } = require('./helpers') +const { MAX_BUILT_IN_SCOPE_ID } = require('./constants') module.exports = class DisplayLayer { @@ -54,7 +54,7 @@ class DisplayLayer { this.rightmostScreenPosition = params.rightmostScreenPosition this.indexedBufferRowCount = params.indexedBufferRowCount } else { - this.spatialIndex = new Patch({mergeAdjacentHunks: false}) + this.spatialIndex = new Patch({ mergeAdjacentHunks: false }) this.tabCounts = [] this.screenLineLengths = [] this.rightmostScreenPosition = Point(0, 0) @@ -66,7 +66,7 @@ class DisplayLayer { static deserialize (buffer, params) { const foldsMarkerLayer = buffer.getMarkerLayer(params.foldsMarkerLayerId) - return new DisplayLayer(params.id, buffer, {foldsMarkerLayer}) + return new DisplayLayer(params.id, buffer, { foldsMarkerLayer }) } serialize () { @@ -194,11 +194,11 @@ class DisplayLayer { foldBufferRange (bufferRange) { bufferRange = Range.fromObject(bufferRange) - const containingFoldMarkers = this.foldsMarkerLayer.findMarkers({containsRange: bufferRange}) + const containingFoldMarkers = this.foldsMarkerLayer.findMarkers({ containsRange: bufferRange }) if (containingFoldMarkers.length === 0) { this.populateSpatialIndexIfNeeded(bufferRange.end.row + 1, Infinity) } - const foldId = this.foldsMarkerLayer.markRange(bufferRange, {invalidate: 'overlap', exclusive: true}).id + const foldId = this.foldsMarkerLayer.markRange(bufferRange, { invalidate: 'overlap', exclusive: true }).id if (containingFoldMarkers.length === 0) { const foldStartRow = bufferRange.start.row const foldEndRow = bufferRange.end.row + 1 @@ -299,7 +299,7 @@ class DisplayLayer { } translateBufferPositionWithSpatialIndex (bufferPosition, clipDirection) { - let hunk = this.spatialIndex.changeForOldPosition(bufferPosition) + const hunk = this.spatialIndex.changeForOldPosition(bufferPosition) if (hunk) { if (compare(bufferPosition, hunk.oldEnd) < 0) { if (compare(hunk.oldStart, bufferPosition) === 0) { @@ -364,7 +364,7 @@ class DisplayLayer { } translateScreenPositionWithSpatialIndex (screenPosition, clipDirection, skipSoftWrapIndentation) { - let hunk = this.spatialIndex.changeForNewPosition(screenPosition) + const hunk = this.spatialIndex.changeForNewPosition(screenPosition) if (hunk) { if (compare(screenPosition, hunk.newEnd) < 0) { if (this.isSoftWrapHunk(hunk)) { @@ -401,7 +401,7 @@ class DisplayLayer { } constrainScreenPosition (screenPosition, clipDirection) { - let {row, column} = screenPosition + const { row, column } = screenPosition if (row < 0) { return new Point(0, 0) @@ -434,7 +434,7 @@ class DisplayLayer { let hunkIndex = 0 let unexpandedScreenColumn = 0 let expandedScreenColumn = 0 - let {row: bufferRow, column: bufferColumn} = this.translateScreenPositionWithSpatialIndex(screenRowStart) + let { row: bufferRow, column: bufferColumn } = this.translateScreenPositionWithSpatialIndex(screenRowStart) let bufferLine = this.buffer.lineForRow(bufferRow) while (tabCount > 0) { @@ -442,14 +442,14 @@ class DisplayLayer { break } - let nextHunk = hunks[hunkIndex] + const nextHunk = hunks[hunkIndex] if (nextHunk && nextHunk.oldStart.row === bufferRow && nextHunk.oldStart.column === bufferColumn) { if (this.isSoftWrapHunk(nextHunk)) { if (hunkIndex !== 0) throw new Error('Unexpected soft wrap hunk') unexpandedScreenColumn = hunks[0].newEnd.column expandedScreenColumn = unexpandedScreenColumn } else { - ({row: bufferRow, column: bufferColumn} = nextHunk.oldEnd) + ({ row: bufferRow, column: bufferColumn } = nextHunk.oldEnd) bufferLine = this.buffer.lineForRow(bufferRow) unexpandedScreenColumn++ expandedScreenColumn++ @@ -485,7 +485,7 @@ class DisplayLayer { let hunkIndex = 0 let unexpandedScreenColumn = 0 let expandedScreenColumn = 0 - let {row: bufferRow, column: bufferColumn} = this.translateScreenPositionWithSpatialIndex(screenRowStart) + let { row: bufferRow, column: bufferColumn } = this.translateScreenPositionWithSpatialIndex(screenRowStart) let bufferLine = this.buffer.lineForRow(bufferRow) while (tabCount > 0) { @@ -493,14 +493,14 @@ class DisplayLayer { break } - let nextHunk = hunks[hunkIndex] + const nextHunk = hunks[hunkIndex] if (nextHunk && nextHunk.oldStart.row === bufferRow && nextHunk.oldStart.column === bufferColumn) { if (this.isSoftWrapHunk(nextHunk)) { if (hunkIndex !== 0) throw new Error('Unexpected soft wrap hunk') unexpandedScreenColumn = Math.min(targetScreenPosition.column, nextHunk.newEnd.column) expandedScreenColumn = unexpandedScreenColumn } else { - ({row: bufferRow, column: bufferColumn} = nextHunk.oldEnd) + ({ row: bufferRow, column: bufferColumn } = nextHunk.oldEnd) bufferLine = this.buffer.lineForRow(bufferRow) unexpandedScreenColumn++ expandedScreenColumn++ @@ -542,7 +542,7 @@ class DisplayLayer { } getClipColumnDelta (bufferPosition, clipDirection) { - var {row, column} = bufferPosition + var { row, column } = bufferPosition // Treat paired unicode characters as atomic... var character = this.buffer.getCharacterAtPosition(bufferPosition) @@ -563,7 +563,7 @@ class DisplayLayer { return 0 } - for (let position = {row, column}; position.column >= 0; position.column--) { + for (let position = { row, column }; position.column >= 0; position.column--) { if (this.buffer.getCharacterAtPosition(position) !== ' ') return 0 } @@ -573,7 +573,7 @@ class DisplayLayer { // If there is a non-whitespace character before the next tab stop, // don't this whitespace as a soft tab - for (let position = {row, column}; position.column < nextTabStop; position.column++) { + for (let position = { row, column }; position.column < nextTabStop; position.column++) { if (this.buffer.getCharacterAtPosition(position) !== ' ') return 0 } @@ -704,7 +704,7 @@ class DisplayLayer { findTrailingWhitespaceStartColumn (bufferRow) { let position - for (position = {row: bufferRow, column: this.buffer.lineLengthForRow(bufferRow) - 1}; position.column >= 0; position.column--) { + for (position = { row: bufferRow, column: this.buffer.lineLengthForRow(bufferRow) - 1 }; position.column >= 0; position.column--) { const previousCharacter = this.buffer.getCharacterAtPosition(position) if (previousCharacter !== ' ' && previousCharacter !== '\t') { break @@ -779,7 +779,7 @@ class DisplayLayer { this.populateSpatialIndexIfNeeded(endRow + 1, Infinity) } - bufferDidChange ({oldRange, newRange}) { + bufferDidChange ({ oldRange, newRange }) { let startRow = oldRange.start.row let oldEndRow = oldRange.end.row let newEndRow = newRange.end.row @@ -803,7 +803,7 @@ class DisplayLayer { this.didChange(this.updateSpatialIndex(startRow, oldEndRow + 1, newEndRow + 1, Infinity)) } - didChange ({start, oldExtent, newExtent}) { + didChange ({ start, oldExtent, newExtent }) { this.changesSinceLastEvent.splice(start, oldExtent, newExtent) if (this.buffer.transactCallDepth === 0) this.emitDeferredChangeEvents() } @@ -832,12 +832,12 @@ class DisplayLayer { oldEndBufferRow = this.findBoundaryFollowingBufferRow(oldEndBufferRow) newEndBufferRow += (oldEndBufferRow - originalOldEndBufferRow) - const startScreenRow = this.translateBufferPositionWithSpatialIndex({row: startBufferRow, column: 0}, 'backward').row - const oldEndScreenRow = this.translateBufferPositionWithSpatialIndex({row: oldEndBufferRow, column: 0}, 'backward').row + const startScreenRow = this.translateBufferPositionWithSpatialIndex({ row: startBufferRow, column: 0 }, 'backward').row + const oldEndScreenRow = this.translateBufferPositionWithSpatialIndex({ row: oldEndBufferRow, column: 0 }, 'backward').row this.spatialIndex.spliceOld( - {row: startBufferRow, column: 0}, - {row: oldEndBufferRow - startBufferRow, column: 0}, - {row: newEndBufferRow - startBufferRow, column: 0} + { row: startBufferRow, column: 0 }, + { row: oldEndBufferRow - startBufferRow, column: 0 }, + { row: newEndBufferRow - startBufferRow, column: 0 } ) const folds = this.computeFoldsInBufferRowRange(startBufferRow, newEndBufferRow) @@ -845,7 +845,7 @@ class DisplayLayer { const insertedScreenLineLengths = [] const insertedTabCounts = [] const currentScreenLineTabColumns = [] - let rightmostInsertedScreenPosition = Point(0, -1) + const rightmostInsertedScreenPosition = Point(0, -1) let bufferRow = startBufferRow let screenRow = startScreenRow let bufferColumn = 0 @@ -963,9 +963,9 @@ class DisplayLayer { // and jump to the end of the fold. if (foldEnd) { this.spatialIndex.splice( - {row: screenRow, column: unexpandedScreenColumn}, - traversal(foldEnd, {row: bufferRow, column: bufferColumn}), - {row: 0, column: 1} + { row: screenRow, column: unexpandedScreenColumn }, + traversal(foldEnd, { row: bufferRow, column: bufferColumn }), + { row: 0, column: 1 } ) unexpandedScreenColumn++ expandedScreenColumn++ @@ -1073,8 +1073,8 @@ class DisplayLayer { findBoundaryPrecedingBufferRow (bufferRow) { while (true) { if (bufferRow === 0) return 0 - let screenPosition = this.translateBufferPositionWithSpatialIndex(Point(bufferRow, 0), 'backward') - let bufferPosition = this.translateScreenPositionWithSpatialIndex(Point(screenPosition.row, 0), 'backward', false) + const screenPosition = this.translateBufferPositionWithSpatialIndex(Point(bufferRow, 0), 'backward') + const bufferPosition = this.translateScreenPositionWithSpatialIndex(Point(screenPosition.row, 0), 'backward', false) if (screenPosition.column === 0 && bufferPosition.column === 0) { return bufferPosition.row } else { @@ -1085,7 +1085,7 @@ class DisplayLayer { findBoundaryFollowingBufferRow (bufferRow) { while (true) { - let screenPosition = this.translateBufferPositionWithSpatialIndex(Point(bufferRow, 0), 'forward') + const screenPosition = this.translateBufferPositionWithSpatialIndex(Point(bufferRow, 0), 'forward') if (screenPosition.column === 0) { return bufferRow } else { @@ -1100,7 +1100,7 @@ class DisplayLayer { findBoundaryFollowingScreenRow (screenRow) { while (true) { - let bufferPosition = this.translateScreenPositionWithSpatialIndex(Point(screenRow, 0), 'forward') + const bufferPosition = this.translateScreenPositionWithSpatialIndex(Point(screenRow, 0), 'forward') if (bufferPosition.column === 0) { return [bufferPosition.row, screenRow] } else { @@ -1169,11 +1169,11 @@ class DisplayLayer { setParams (params) { let paramsChanged = false - if (params.hasOwnProperty('tabLength') && params.tabLength !== this.tabLength) { + if (Object.prototype.hasOwnProperty.call(params, 'tabLength') && params.tabLength !== this.tabLength) { paramsChanged = true this.tabLength = params.tabLength } - if (params.hasOwnProperty('invisibles') && !invisiblesEqual(params.invisibles, this.invisibles)) { + if (Object.prototype.hasOwnProperty.call(params, 'invisibles') && !invisiblesEqual(params.invisibles, this.invisibles)) { paramsChanged = true this.invisibles = params.invisibles this.eolInvisibles = { @@ -1182,12 +1182,12 @@ class DisplayLayer { '\r\n': this.invisibles.cr + this.invisibles.eol } } - if (params.hasOwnProperty('showIndentGuides') && params.showIndentGuides !== this.showIndentGuides) { + if (Object.prototype.hasOwnProperty.call(params, 'showIndentGuides') && params.showIndentGuides !== this.showIndentGuides) { paramsChanged = true this.showIndentGuides = params.showIndentGuides } - if (params.hasOwnProperty('softWrapColumn')) { - let softWrapColumn = params.softWrapColumn != null + if (Object.prototype.hasOwnProperty.call(params, 'softWrapColumn')) { + const softWrapColumn = params.softWrapColumn != null ? Math.max(1, params.softWrapColumn) : Infinity if (softWrapColumn !== this.softWrapColumn) { @@ -1195,23 +1195,23 @@ class DisplayLayer { this.softWrapColumn = softWrapColumn } } - if (params.hasOwnProperty('softWrapHangingIndent') && params.softWrapHangingIndent !== this.softWrapHangingIndent) { + if (Object.prototype.hasOwnProperty.call(params, 'softWrapHangingIndent') && params.softWrapHangingIndent !== this.softWrapHangingIndent) { paramsChanged = true this.softWrapHangingIndent = params.softWrapHangingIndent } - if (params.hasOwnProperty('ratioForCharacter') && params.ratioForCharacter !== this.ratioForCharacter) { + if (Object.prototype.hasOwnProperty.call(params, 'ratioForCharacter') && params.ratioForCharacter !== this.ratioForCharacter) { paramsChanged = true this.ratioForCharacter = params.ratioForCharacter } - if (params.hasOwnProperty('isWrapBoundary') && params.isWrapBoundary !== this.isWrapBoundary) { + if (Object.prototype.hasOwnProperty.call(params, 'isWrapBoundary') && params.isWrapBoundary !== this.isWrapBoundary) { paramsChanged = true this.isWrapBoundary = params.isWrapBoundary } - if (params.hasOwnProperty('foldCharacter') && params.foldCharacter !== this.foldCharacter) { + if (Object.prototype.hasOwnProperty.call(params, 'foldCharacter') && params.foldCharacter !== this.foldCharacter) { paramsChanged = true this.foldCharacter = params.foldCharacter } - if (params.hasOwnProperty('atomicSoftTabs') && params.atomicSoftTabs !== this.atomicSoftTabs) { + if (Object.prototype.hasOwnProperty.call(params, 'atomicSoftTabs') && params.atomicSoftTabs !== this.atomicSoftTabs) { paramsChanged = true this.atomicSoftTabs = params.atomicSoftTabs } @@ -1224,10 +1224,10 @@ class DisplayLayer { } function invisiblesEqual (left, right) { - let leftKeys = Object.keys(left) - let rightKeys = Object.keys(right) + const leftKeys = Object.keys(left) + const rightKeys = Object.keys(right) if (leftKeys.length !== rightKeys.length) return false - for (let key of leftKeys) { + for (const key of leftKeys) { if (left[key] !== right[key]) return false } return true diff --git a/src/helpers.js b/src/helpers.js index 094685521d..bdb36e250d 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,6 +1,6 @@ -const {Patch} = require('superstring') +const { Patch } = require('superstring') const Range = require('./range') -const {traversal} = require('./point-helpers') +const { traversal } = require('./point-helpers') const LF_REGEX = /\n/g @@ -52,7 +52,7 @@ exports.spliceArray = function (array, start, removedCount, insertedItems = []) exports.patchFromChanges = function (changes) { const patch = new Patch() for (let i = 0; i < changes.length; i++) { - const {oldStart, oldEnd, oldText, newStart, newEnd, newText} = changes[i] + const { oldStart, oldEnd, oldText, newStart, newEnd, newText } = changes[i] const oldExtent = traversal(oldEnd, oldStart) const newExtent = traversal(newEnd, newStart) patch.splice(newStart, oldExtent, newExtent, oldText, newText) @@ -78,7 +78,7 @@ exports.extentForText = function (text) { row++ lastLineStartIndex = LF_REGEX.lastIndex } - return {row, column: text.length - lastLineStartIndex} + return { row, column: text.length - lastLineStartIndex } } class TextChange { diff --git a/src/null-language-mode.js b/src/null-language-mode.js index 5025eb5697..6aa6840c71 100644 --- a/src/null-language-mode.js +++ b/src/null-language-mode.js @@ -1,4 +1,4 @@ -const {Disposable} = require('event-kit') +const { Disposable } = require('event-kit') const Point = require('./point') const EMPTY = [] diff --git a/src/screen-line-builder.js b/src/screen-line-builder.js index 52874a0e82..6412c614a9 100644 --- a/src/screen-line-builder.js +++ b/src/screen-line-builder.js @@ -271,7 +271,7 @@ class ScreenLineBuilder { emitLineEnding () { this.emitCloseTag(this.getBuiltInScopeId(this.currentBuiltInClassNameFlags)) - let lineEnding = this.displayLayer.buffer.lineEndingForRow(this.bufferPosition.row) + const lineEnding = this.displayLayer.buffer.lineEndingForRow(this.bufferPosition.row) const eolInvisible = this.displayLayer.eolInvisibles[lineEnding] if (eolInvisible) { let eolFlags = INVISIBLE_CHARACTER | LINE_ENDING @@ -282,7 +282,7 @@ class ScreenLineBuilder { } if (this.bufferLineLength === 0 && this.displayLayer.showIndentGuides) { - let whitespaceLength = this.displayLayer.leadingWhitespaceLengthForSurroundingLines(this.bufferPosition.row) + const whitespaceLength = this.displayLayer.leadingWhitespaceLengthForSurroundingLines(this.bufferPosition.row) this.emitIndentWhitespace(whitespaceLength) } diff --git a/src/text-buffer.js b/src/text-buffer.js index df1f4775fb..f2759c92b2 100644 --- a/src/text-buffer.js +++ b/src/text-buffer.js @@ -1,5 +1,5 @@ -const {Emitter, CompositeDisposable} = require('event-kit') -const {File} = require('pathwatcher') +const { Emitter, CompositeDisposable } = require('event-kit') +const { File } = require('pathwatcher') const diff = require('diff') const _ = require('underscore-plus') const path = require('path') @@ -14,8 +14,8 @@ const NullLanguageMode = require('./null-language-mode') const Marker = require('./marker') const MarkerLayer = require('./marker-layer') const DisplayLayer = require('./display-layer') -const {spliceArray, newlineRegex, patchFromChanges, normalizePatchChanges, extentForText, debounce} = require('./helpers') -const {traverse, traversal} = require('./point-helpers') +const { spliceArray, newlineRegex, patchFromChanges, normalizePatchChanges, extentForText, debounce } = require('./helpers') +const { traverse, traversal } = require('./point-helpers') const Grim = require('grim') // Extended: A mutable text container with undo/redo support and the ability to @@ -119,7 +119,7 @@ class TextBuffer { 'The `load` option to the TextBuffer constructor is deprecated. ' + 'Get a loaded buffer using TextBuffer.load(filePath) instead.' ) - this.load({internal: true}) + this.load({ internal: true }) } } } @@ -147,7 +147,7 @@ class TextBuffer { buffer.setFile(source) } return buffer - .load({clearHistory: true, internal: true, mustExist: params && params.mustExist}) + .load({ clearHistory: true, internal: true, mustExist: params && params.mustExist }) .then(() => buffer) .catch(err => { buffer.destroy() @@ -170,7 +170,7 @@ class TextBuffer { const buffer = new TextBuffer(params) buffer.setPath(filePath) try { - buffer.loadSync({internal: true, mustExist: params && params.mustExist}) + buffer.loadSync({ internal: true, mustExist: params && params.mustExist }) } catch (e) { buffer.destroy() throw e @@ -600,7 +600,7 @@ class TextBuffer { } this.emitter.emit('did-change-encoding', encoding) if (!this.isModified()) { - this.load({clearHistory: true, internal: true}) + this.load({ clearHistory: true, internal: true }) } } else { this.emitter.emit('did-change-encoding', encoding) @@ -777,7 +777,7 @@ class TextBuffer { // // Returns a {Range} spanning the new buffer contents. setText (text) { - return this.setTextInRange(this.getRange(), text, {normalizeLineEndings: false}) + return this.setTextInRange(this.getRange(), text, { normalizeLineEndings: false }) } // Public: Replace the current buffer contents by applying a diff based on the @@ -803,9 +803,9 @@ class TextBuffer { const currentPosition = [0, 0] const lineDiff = diff.diffLines(currentText, text) - const changeOptions = {normalizeLineEndings: false} + const changeOptions = { normalizeLineEndings: false } - for (let change of lineDiff) { + for (const change of lineDiff) { const lineCount = change.count currentPosition[0] = row currentPosition[1] = column @@ -840,14 +840,14 @@ class TextBuffer { // Returns the {Range} of the inserted text. setTextInRange (range, newText, options) { let normalizeLineEndings, undo - if (options) ({normalizeLineEndings, undo} = options) + if (options) ({ normalizeLineEndings, undo } = options) if (normalizeLineEndings == null) normalizeLineEndings = true if (undo != null) { Grim.deprecate('The `undo` option is deprecated. Call groupLastChanges() on the TextBuffer afterward instead.') } if (this.transactCallDepth === 0) { - const newRange = this.transact(() => this.setTextInRange(range, newText, {normalizeLineEndings})) + const newRange = this.transact(() => this.setTextInRange(range, newText, { normalizeLineEndings })) if (undo === 'skip') this.groupLastChanges() return newRange } @@ -909,7 +909,7 @@ class TextBuffer { // Applies a change to the buffer based on its old range and new text. applyChange (change, pushToHistory = false) { - const {newStart, newEnd, oldStart, oldEnd, oldText, newText} = change + const { newStart, newEnd, oldStart, oldEnd, oldText, newText } = change const oldExtent = traversal(oldEnd, oldStart) const oldRange = Range(newStart, traverse(newStart, oldExtent)) @@ -927,7 +927,7 @@ class TextBuffer { } } - const changeEvent = {oldRange, newRange, oldText, newText} + const changeEvent = { oldRange, newRange, oldText, newText } for (const id in this.displayLayers) { const displayLayer = this.displayLayers[id] displayLayer.bufferWillChange(changeEvent) @@ -1304,7 +1304,7 @@ class TextBuffer { fn = options groupingInterval = 0 } else if (typeof options === 'object') { - ({groupingInterval, selectionsMarkerLayer} = options) + ({ groupingInterval, selectionsMarkerLayer } = options) if (groupingInterval == null) { groupingInterval = 0 } } else { groupingInterval = options @@ -1319,7 +1319,7 @@ class TextBuffer { this.transactCallDepth++ result = fn() } catch (exception) { - this.revertToCheckpoint(checkpointBefore, {deleteCheckpoint: true}) + this.revertToCheckpoint(checkpointBefore, { deleteCheckpoint: true }) if (!(exception instanceof TransactionAbortedError)) throw exception return } finally { @@ -1360,7 +1360,7 @@ class TextBuffer { // // Returns a checkpoint id value. createCheckpoint (options) { - return this.historyProvider.createCheckpoint({markers: this.createMarkerSnapshot(options != null ? options.selectionsMarkerLayer : undefined), isBarrier: false}) + return this.historyProvider.createCheckpoint({ markers: this.createMarkerSnapshot(options != null ? options.selectionsMarkerLayer : undefined), isBarrier: false }) } // Public: Revert the buffer to the state it was in when the given @@ -1608,7 +1608,7 @@ class TextBuffer { let replacements = 0 this.transact(() => { - return this.scan(regex, function ({matchText, replace}) { + return this.scan(regex, function ({ matchText, replace }) { replace(matchText.replace(regex, replacementText)) return replacements++ }) @@ -1859,7 +1859,7 @@ class TextBuffer { clipPosition (position, options) { position = Point.fromObject(position) Point.assertValid(position) - const {row, column} = position + const { row, column } = position if (row < 0) { return this.getFirstPosition() } else if (row > this.getLastRow()) { @@ -1920,7 +1920,7 @@ class TextBuffer { destination = file.createWriteStream() } - await this.emitter.emitAsync('will-save', {path: filePath}) + await this.emitter.emitAsync('will-save', { path: filePath }) try { await this.buffer.save(destination, this.getEncoding()) @@ -1946,7 +1946,7 @@ class TextBuffer { this.digestWhenLastPersisted = this.buffer.baseTextDigest() this.loaded = true this.emitModifiedStatusChanged(false) - this.emitter.emit('did-save', {path: filePath}) + this.emitter.emit('did-save', { path: filePath }) return this } @@ -1954,7 +1954,7 @@ class TextBuffer { // // Returns a {Promise} that resolves when the load is complete. reload () { - return this.load({discardChanges: true, internal: true}) + return this.load({ discardChanges: true, internal: true }) } /* @@ -1974,7 +1974,7 @@ class TextBuffer { setDisplayLayers (displayLayers) { this.displayLayers = displayLayers - // Used for deserialization + // Used for deserialization } /* @@ -2019,7 +2019,7 @@ class TextBuffer { const displayLayer = this.displayLayers[id] displayLayer.bufferDidChangeLanguageMode(languageMode) } - this.emitter.emit('did-change-language-mode', {newMode: this.languageMode, oldMode: oldLanguageMode}) + this.emitter.emit('did-change-language-mode', { newMode: this.languageMode, oldMode: oldLanguageMode }) } } @@ -2033,7 +2033,7 @@ class TextBuffer { // // Returns a {Disposable} that can be used to stop the callback from being called. onDidChangeLanguageMode (callback) { - return this.emitter.on('did-change-language-mode', ({newMode, oldMode}) => callback(newMode, oldMode)) + return this.emitter.on('did-change-language-mode', ({ newMode, oldMode }) => callback(newMode, oldMode)) } /* @@ -2104,7 +2104,7 @@ class TextBuffer { if (this.loadCount > loadCount) return false if (patch) { if (patch.getChangeCount() > 0) { - checkpoint = this.historyProvider.createCheckpoint({markers: this.createMarkerSnapshot(), isBarrier: true}) + checkpoint = this.historyProvider.createCheckpoint({ markers: this.createMarkerSnapshot(), isBarrier: true }) this.emitter.emit('will-reload') return this.emitWillChangeEvent() } else if (options && options.discardChanges) { @@ -2253,7 +2253,7 @@ class TextBuffer { this.emitter.emit('did-conflict') } } else { - return this.load({internal: true}) + return this.load({ internal: true }) } }, this.fileChangeDelay))) } @@ -2383,7 +2383,7 @@ class TextBuffer { patchFromChanges(this.changesSinceLastStoppedChangingEvent).getChanges() )) this.changesSinceLastStoppedChangingEvent.length = 0 - this.emitter.emit('did-stop-changing', {changes: compactedChanges}) + this.emitter.emit('did-stop-changing', { changes: compactedChanges }) this.emitModifiedStatusChanged(modifiedStatus) } @@ -2493,7 +2493,7 @@ class ChangeEvent { this.changes = Object.freeze(normalizePatchChanges(changes)) const start = changes[0].oldStart - const {oldEnd, newEnd} = changes[changes.length - 1] + const { oldEnd, newEnd } = changes[changes.length - 1] this.oldRange = new Range(start, oldEnd).freeze() this.newRange = new Range(start, newEnd).freeze() From 270ce1d1ab0a12c4962786241f6e3bcff67a06a9 Mon Sep 17 00:00:00 2001 From: sidneys Date: Mon, 26 Aug 2019 14:52:21 +0200 Subject: [PATCH 4/4] fix(dependencies): use git commit hash to explicitly reference the minimum version of the substring package required to fully support Nodejs 12 environments --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96419c3531..c5c5f73092 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "rimraf": "~3.0.0", "serializable": "^1.0.3", "standard": "^14.0.2", - "superstring": "git+https://git@github.com/atom/superstring.git#master", + "superstring": "git+https://git@github.com/atom/superstring.git#59c92f", "underscore-plus": "^1.7.0" }, "standard": {