diff --git a/.coffeelintignore b/.coffeelintignore new file mode 100644 index 000000000..5c4e30278 --- /dev/null +++ b/.coffeelintignore @@ -0,0 +1,2 @@ +spec/fixtures +benchmark/fixtures diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe9a742b4..333eb0913 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,6 +100,9 @@ For more information on how to work with Atom's official packages, see * Set parameter defaults without spaces around the equal sign * `clear = (count=1) ->` instead of `clear = (count = 1) ->` +* Use spaces around operators + * `count + 1` instead of `count+1` +* Use spaces after commas (unless separated by newlines) * Use parentheses if it improves code clarity. * Prefer alphabetic keywords to symbolic keywords: * `a is b` instead of `a == b` @@ -113,6 +116,8 @@ For more information on how to work with Atom's official packages, see * Use `slice()` to copy an array * Add an explicit `return` when your function ends with a `for`/`while` loop and you don't want it to return a collected array. +* Use `this` instead of a standalone `@` + * `return this` instead of `return @` ## Specs Styleguide diff --git a/build/tasks/build-task.coffee b/build/tasks/build-task.coffee index 343960f61..6c2c4f309 100644 --- a/build/tasks/build-task.coffee +++ b/build/tasks/build-task.coffee @@ -103,6 +103,8 @@ module.exports = (grunt) -> '.lintignore' '.eslintrc' '.jshintignore' + 'coffeelint.json' + '.coffeelintignore' '.gitattributes' '.gitkeep' ] diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 5131f512c..71d3c4ae8 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -31,7 +31,7 @@ module.exports = (grunt) -> binDir = path.join(installDir, 'bin') shareDir = path.join(installDir, 'share', 'atom') - iconName = path.join(shareDir,'resources', 'app', 'resources', 'atom.png') + iconName = path.join(shareDir, 'resources', 'app', 'resources', 'atom.png') mkdir binDir cp 'atom.sh', path.join(binDir, 'atom') diff --git a/coffeelint.json b/coffeelint.json index f3caf09cc..a5dd715e3 100644 --- a/coffeelint.json +++ b/coffeelint.json @@ -27,5 +27,11 @@ "braces_spacing": { "spaces": 0, "level": "error" + }, + "spacing_after_comma": { + "level": "error" + }, + "no_stand_alone_at": { + "level": "error" } } diff --git a/docs/build-instructions/freebsd.md b/docs/build-instructions/freebsd.md index 147c9da23..8029aa5f2 100644 --- a/docs/build-instructions/freebsd.md +++ b/docs/build-instructions/freebsd.md @@ -19,4 +19,18 @@ FreeBSD -RELEASE 64-bit is the recommended platform. sudo script/grunt install # Installs command to /usr/local/bin/atom ``` +## Advanced Options + +### Custom install directory + +```sh +sudo script/grunt install --install-dir /install/atom/here +``` + +### Custom build directory + +```sh +script/build --build-dir /build/atom/here +``` + ## Troubleshooting diff --git a/docs/build-instructions/os-x.md b/docs/build-instructions/os-x.md index d8685cff8..7201676b1 100644 --- a/docs/build-instructions/os-x.md +++ b/docs/build-instructions/os-x.md @@ -14,6 +14,11 @@ script/build # Creates application at /Applications/Atom.app ``` +### `script/build` Options + * `--install-dir` - The full path to the final built application (must include `.app` in the path), e.g. `script/build --install-dir /Users/username/full/path/to/Atom.app` + * `--build-dir` - Build the application in this directory. + * `--verbose` - Verbose mode. A lot more information output. + ## Troubleshooting ### OSX build error reports in atom/atom diff --git a/docs/build-instructions/windows.md b/docs/build-instructions/windows.md index 8cfe74e72..a5d0757cb 100644 --- a/docs/build-instructions/windows.md +++ b/docs/build-instructions/windows.md @@ -33,6 +33,11 @@ cd atom script/build # Creates application in the `Program Files` directory ``` +### `script/build` Options + * `--install-dir` - Creates the final built application in this directory. + * `--build-dir` - Build the application in this directory. + * `--verbose` - Verbose mode. A lot more information output. + ## Why do I have to use GitHub for Windows? You don't. You can use your existing Git! GitHub for Windows's Git Shell is just diff --git a/docs/contributing-to-packages.md b/docs/contributing-to-packages.md index 42de6e37b..4576635ff 100644 --- a/docs/contributing-to-packages.md +++ b/docs/contributing-to-packages.md @@ -40,9 +40,8 @@ For this reason, you'll only want to load packages in **development mode** while you are working on them. You'll perform your editing in **stable mode**, only switching to development mode to test your changes. -To open a development mode window, use the "Application: Open Dev" command, -which is normally bound to `cmd-shift-o`. You can also run dev mode from the -command line with `atom --dev`. +To open a development mode window, use the "Application: Open Dev" command. +You can also run dev mode from the command line with `atom --dev`. To load your package in development mode, create a symlink to it in `~/.atom/dev/packages`. This occurs automatically when you clone the package diff --git a/package.json b/package.json index be07a083a..54ef562b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom", "productName": "Atom", - "version": "0.202.0", + "version": "0.205.0", "description": "A hackable text editor for the 21st Century.", "main": "./src/browser/main.js", "repository": { @@ -20,7 +20,7 @@ "atomShellVersion": "0.22.3", "dependencies": { "async": "0.2.6", - "atom-keymap": "^5.1.2", + "atom-keymap": "^5.1.5", "atom-space-pen-views": "^2.0.4", "babel-core": "^5.1.11", "bootstrap": "^3.3.4", @@ -64,7 +64,7 @@ "space-pen": "3.8.2", "stacktrace-parser": "0.1.1", "temp": "0.8.1", - "text-buffer": "6.0.2", + "text-buffer": "6.1.3", "theorist": "^1.0.2", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", @@ -77,29 +77,29 @@ "atom-light-ui": "0.41.0", "base16-tomorrow-dark-theme": "0.26.0", "base16-tomorrow-light-theme": "0.9.0", - "one-dark-ui": "0.8.2", - "one-dark-syntax": "0.5.0", - "one-light-syntax": "0.6.0", - "one-light-ui": "0.8.2", + "one-dark-ui": "0.9.0", + "one-dark-syntax": "0.7.0", + "one-light-syntax": "0.7.0", + "one-light-ui": "0.9.0", "solarized-dark-syntax": "0.35.0", "solarized-light-syntax": "0.21.0", "archive-view": "0.57.0", "autocomplete-atom-api": "0.9.0", "autocomplete-css": "0.7.2", "autocomplete-html": "0.7.2", - "autocomplete-plus": "2.17.1", - "autocomplete-snippets": "1.6.1", + "autocomplete-plus": "2.17.3", + "autocomplete-snippets": "1.6.3", "autoflow": "0.24.0", "autosave": "0.20.0", - "background-tips": "0.24.0", + "background-tips": "0.25.0", "bookmarks": "0.35.0", "bracket-matcher": "0.74.0", "command-palette": "0.36.0", - "deprecation-cop": "0.51.0", + "deprecation-cop": "0.52.0", "dev-live-reload": "0.46.0", "encoding-selector": "0.20.0", "exception-reporting": "0.24.0", - "find-and-replace": "0.167.0", + "find-and-replace": "0.170.0", "fuzzy-finder": "0.87.0", "git-diff": "0.55.0", "go-to-line": "0.30.0", @@ -108,37 +108,37 @@ "incompatible-packages": "0.24.0", "keybinding-resolver": "0.33.0", "link": "0.30.0", - "markdown-preview": "0.149.0", + "markdown-preview": "0.150.0", "metrics": "0.51.0", "notifications": "0.50.0", "open-on-github": "0.37.0", "package-generator": "0.39.0", "release-notes": "0.52.0", - "settings-view": "0.205.0", - "snippets": "0.90.0", + "settings-view": "0.206.0", + "snippets": "0.91.0", "spell-check": "0.58.0", - "status-bar": "0.72.0", + "status-bar": "0.74.0", "styleguide": "0.44.0", "symbols-view": "0.97.0", - "tabs": "0.68.0", + "tabs": "0.69.0", "timecop": "0.31.0", "tree-view": "0.171.0", "update-package-dependencies": "0.10.0", "welcome": "0.27.0", "whitespace": "0.29.0", - "wrap-guide": "0.33.0", - "language-c": "0.44.0", + "wrap-guide": "0.35.0", + "language-c": "0.45.0", "language-clojure": "0.15.0", "language-coffee-script": "0.40.0", "language-csharp": "0.5.0", - "language-css": "0.29.0", + "language-css": "0.30.0", "language-gfm": "0.76.0", "language-git": "0.10.0", "language-go": "0.26.0", - "language-html": "0.37.0", + "language-html": "0.38.0", "language-hyperlink": "0.13.0", "language-java": "0.15.0", - "language-javascript": "0.77.0", + "language-javascript": "0.78.0", "language-json": "0.14.0", "language-less": "0.27.0", "language-make": "0.14.0", @@ -148,14 +148,14 @@ "language-php": "0.24.0", "language-property-list": "0.8.0", "language-python": "0.35.0", - "language-ruby": "0.54.0", + "language-ruby": "0.56.0", "language-ruby-on-rails": "0.21.0", "language-sass": "0.38.0", "language-shellscript": "0.15.0", "language-source": "0.9.0", "language-sql": "0.15.0", "language-text": "0.6.0", - "language-todo": "0.21.0", + "language-todo": "0.23.0", "language-toml": "0.16.0", "language-xml": "0.30.0", "language-yaml": "0.22.0" diff --git a/resources/linux/redhat/atom.spec.in b/resources/linux/redhat/atom.spec.in index 3bc37e83a..2bd89cb9a 100644 --- a/resources/linux/redhat/atom.spec.in +++ b/resources/linux/redhat/atom.spec.in @@ -7,7 +7,7 @@ URL: https://atom.io/ AutoReqProv: no # Avoid libchromiumcontent.so missing dependency Prefix: <%= installDir %> -Requires: redhat-lsb-core +Requires: lsb %description <%= description %> diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index be89db8ac..140ca2f9e 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -44,7 +44,7 @@ describe "DisplayBuffer", -> it "renders line numbers correctly", -> originalLineCount = displayBuffer.getLineCount() oneHundredLines = [0..100].join("\n") - buffer.insert([0,0], oneHundredLines) + buffer.insert([0, 0], oneHundredLines) expect(displayBuffer.getLineCount()).toBe 100 + originalLineCount it "reassigns the scrollTop if it exceeds the max possible value after lines are removed", -> @@ -382,10 +382,10 @@ describe "DisplayBuffer", -> describe "when creating a fold where one already exists", -> it "returns existing fold and does't create new fold", -> - fold = displayBuffer.createFold(0,10) + fold = displayBuffer.createFold(0, 10) expect(displayBuffer.findMarkers(class: 'fold').length).toBe 1 - newFold = displayBuffer.createFold(0,10) + newFold = displayBuffer.createFold(0, 10) expect(newFold).toBe fold expect(displayBuffer.findMarkers(class: 'fold').length).toBe 1 diff --git a/spec/language-mode-spec.coffee b/spec/language-mode-spec.coffee index 47fa30bdf..9c4fc2c1e 100644 --- a/spec/language-mode-spec.coffee +++ b/spec/language-mode-spec.coffee @@ -134,23 +134,23 @@ describe "LanguageMode", -> it "will limit paragraph range to comments", -> range = languageMode.rowRangeForParagraphAtBufferRow(0) - expect(range).toEqual [[0,0], [0,29]] + expect(range).toEqual [[0, 0], [0, 29]] range = languageMode.rowRangeForParagraphAtBufferRow(10) - expect(range).toEqual [[10,0], [10,14]] + expect(range).toEqual [[10, 0], [10, 14]] range = languageMode.rowRangeForParagraphAtBufferRow(11) expect(range).toBeFalsy() range = languageMode.rowRangeForParagraphAtBufferRow(12) - expect(range).toEqual [[12,0], [13,10]] + expect(range).toEqual [[12, 0], [13, 10]] range = languageMode.rowRangeForParagraphAtBufferRow(14) - expect(range).toEqual [[14,0], [14,32]] + expect(range).toEqual [[14, 0], [14, 32]] range = languageMode.rowRangeForParagraphAtBufferRow(15) - expect(range).toEqual [[15,0], [15,26]] + expect(range).toEqual [[15, 0], [15, 26]] range = languageMode.rowRangeForParagraphAtBufferRow(18) - expect(range).toEqual [[17,0], [19,3]] + expect(range).toEqual [[17, 0], [19, 3]] describe "coffeescript", -> beforeEach -> @@ -305,9 +305,9 @@ describe "LanguageMode", -> atom.packages.unloadPackages() it "maintains cursor buffer position when a folding/unfolding", -> - editor.setCursorBufferPosition([5,5]) + editor.setCursorBufferPosition([5, 5]) languageMode.foldAll() - expect(editor.getCursorBufferPosition()).toEqual([5,5]) + expect(editor.getCursorBufferPosition()).toEqual([5, 5]) describe ".unfoldAll()", -> it "unfolds every folded line", -> @@ -359,7 +359,7 @@ describe "LanguageMode", -> describe "when the bufferRow is in a multi-line comment", -> it "searches upward and downward for surrounding comment lines and folds them as a single fold", -> - buffer.insert([1,0], " //this is a comment\n // and\n //more docs\n\n//second comment") + buffer.insert([1, 0], " //this is a comment\n // and\n //more docs\n\n//second comment") languageMode.foldBufferRow(1) fold = editor.tokenizedLineForScreenRow(1).fold expect(fold.getStartRow()).toBe 1 @@ -367,7 +367,7 @@ describe "LanguageMode", -> describe "when the bufferRow is a single-line comment", -> it "searches upward for the first row that begins a syntatic region containing the folded row (and folds it)", -> - buffer.insert([1,0], " //this is a single line comment\n") + buffer.insert([1, 0], " //this is a single line comment\n") languageMode.foldBufferRow(1) fold = editor.tokenizedLineForScreenRow(0).fold expect(fold.getStartRow()).toBe 0 diff --git a/spec/menu-manager-spec.coffee b/spec/menu-manager-spec.coffee index d92c921c4..f86b6e1a0 100644 --- a/spec/menu-manager-spec.coffee +++ b/spec/menu-manager-spec.coffee @@ -1,3 +1,4 @@ +path = require 'path' MenuManager = require '../src/menu-manager' describe "MenuManager", -> @@ -46,3 +47,32 @@ describe "MenuManager", -> menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}] menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}] expect(menu.template[originalItemCount]).toEqual {label: "A", submenu: [{label: "B", command: "b"}]} + + describe "::update()", -> + it "sends the current menu template and associated key bindings to the browser process", -> + spyOn(menu, 'sendToBrowserProcess') + menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}] + atom.keymap.add 'test', 'atom-workspace': 'ctrl-b': 'b' + menu.update() + + waits 1 + + runs -> expect(menu.sendToBrowserProcess.argsForCall[0][1]['b']).toEqual ['ctrl-b'] + + it "omits key bindings that are mapped to unset! in any context", -> + # it would be nice to be smarter about omitting, but that would require a much + # more dynamic interaction between the currently focused element and the menu + spyOn(menu, 'sendToBrowserProcess') + menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}] + atom.keymap.add 'test', 'atom-workspace': 'ctrl-b': 'b' + atom.keymap.add 'test', 'atom-text-editor': 'ctrl-b': 'unset!' + + waits 1 + + runs -> expect(menu.sendToBrowserProcess.argsForCall[0][1]['b']).toBeUndefined() + + it "updates the application menu when a keymap is reloaded", -> + spyOn(menu, 'update') + keymapPath = path.join(__dirname, 'fixtures', 'packages', 'package-with-keymaps', 'keymaps', 'keymap-1.cson') + atom.keymaps.reloadKeymap(keymapPath) + expect(menu.update).toHaveBeenCalled() diff --git a/spec/selection-spec.coffee b/spec/selection-spec.coffee index 0e64b60fd..bdccb799d 100644 --- a/spec/selection-spec.coffee +++ b/spec/selection-spec.coffee @@ -14,18 +14,18 @@ describe "Selection", -> describe ".deleteSelectedText()", -> describe "when nothing is selected", -> it "deletes nothing", -> - selection.setBufferRange [[0,3], [0,3]] + selection.setBufferRange [[0, 3], [0, 3]] selection.deleteSelectedText() expect(buffer.lineForRow(0)).toBe "var quicksort = function () {" describe "when one line is selected", -> it "deletes selected text and clears the selection", -> - selection.setBufferRange [[0,4], [0,14]] + selection.setBufferRange [[0, 4], [0, 14]] selection.deleteSelectedText() expect(buffer.lineForRow(0)).toBe "var = function () {" endOfLine = buffer.lineForRow(0).length - selection.setBufferRange [[0,0], [0, endOfLine]] + selection.setBufferRange [[0, 0], [0, endOfLine]] selection.deleteSelectedText() expect(buffer.lineForRow(0)).toBe "" @@ -33,15 +33,15 @@ describe "Selection", -> describe "when multiple lines are selected", -> it "deletes selected text and clears the selection", -> - selection.setBufferRange [[0,1], [2,39]] + selection.setBufferRange [[0, 1], [2, 39]] selection.deleteSelectedText() expect(buffer.lineForRow(0)).toBe "v;" expect(selection.isEmpty()).toBeTruthy() describe "when the cursor precedes the tail", -> it "deletes selected text and clears the selection", -> - selection.cursor.setScreenPosition [0,13] - selection.selectToScreenPosition [0,4] + selection.cursor.setScreenPosition [0, 13] + selection.selectToScreenPosition [0, 4] selection.delete() expect(buffer.lineForRow(0)).toBe "var = function () {" diff --git a/spec/text-editor-element-spec.coffee b/spec/text-editor-element-spec.coffee index 435b3a4a5..ea5f55968 100644 --- a/spec/text-editor-element-spec.coffee +++ b/spec/text-editor-element-spec.coffee @@ -83,7 +83,7 @@ describe "TextEditorElement", -> editor = new TextEditor editor.setText('1\n2\n3') editor.addGutter({name: 'test-gutter'}) - marker = editor.markBufferRange([[0,0],[2,0]]) + marker = editor.markBufferRange([[0, 0], [2, 0]]) editor.decorateMarker(marker, {type: 'gutter', gutterName: 'test-gutter'}) element = atom.views.getView(editor) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 6a1b2a6d0..0d5c5cffb 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -2260,11 +2260,11 @@ describe "TextEditorPresenter", -> gutterName: 'test-gutter' class: 'test-class' item: decorationItem - marker1 = editor.markBufferRange([[0,0],[1,0]]) + marker1 = editor.markBufferRange([[0, 0], [1, 0]]) decoration1 = editor.decorateMarker(marker1, decorationParams) - marker2 = editor.markBufferRange([[9,0],[12,0]]) + marker2 = editor.markBufferRange([[9, 0], [12, 0]]) decoration2 = editor.decorateMarker(marker2, decorationParams) - marker3 = editor.markBufferRange([[13,0],[14,0]]) + marker3 = editor.markBufferRange([[13, 0], [14, 0]]) decoration3 = editor.decorateMarker(marker3, decorationParams) # Clear any batched state updates. @@ -2313,7 +2313,7 @@ describe "TextEditorPresenter", -> it "updates when the editor's content changes", -> # This update will add enough lines to push decoration2 out of view. - expectStateUpdate presenter, -> editor.setTextInBufferRange([[8,0],[9,0]],'\n\n\n\n\n') + expectStateUpdate presenter, -> editor.setTextInBufferRange([[8, 0], [9, 0]], '\n\n\n\n\n') decorationState = getContentForGutterWithName(presenter, 'test-gutter') expect(decorationState[decoration1.id].top).toBeDefined() @@ -2323,7 +2323,7 @@ describe "TextEditorPresenter", -> it "updates when a decoration's marker is modified", -> # This update will move decoration1 out of view. expectStateUpdate presenter, -> - newRange = new Range([13,0],[14,0]) + newRange = new Range([13, 0], [14, 0]) marker1.setBufferRange(newRange) decorationState = getContentForGutterWithName(presenter, 'test-gutter') @@ -2434,7 +2434,7 @@ describe "TextEditorPresenter", -> type: 'gutter' gutterName: 'test-gutter-2' class: 'test-class' - marker4 = editor.markBufferRange([[0,0],[1,0]]) + marker4 = editor.markBufferRange([[0, 0], [1, 0]]) decoration4 = editor.decorateMarker(marker4, decorationParams) expectStateUpdate presenter, -> editor.addGutter({name: 'test-gutter-2'}) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index a845619ba..28dbaaff8 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -227,7 +227,7 @@ describe "TextEditor", -> describe "when the cursor moves", -> it "clears a goal column established by vertical movement", -> editor.setText('b') - editor.setCursorBufferPosition([0,0]) + editor.setCursorBufferPosition([0, 0]) editor.insertNewline() editor.moveUp() editor.insertText('a') @@ -262,7 +262,7 @@ describe "TextEditor", -> expect(editor.getCursorScreenPosition().column).not.toBe 6 # clear the goal column by explicitly setting the cursor position - editor.setCursorScreenPosition([4,6]) + editor.setCursorScreenPosition([4, 6]) expect(editor.getCursorScreenPosition().column).toBe 6 editor.moveDown() @@ -317,7 +317,7 @@ describe "TextEditor", -> describe "when there is a selection", -> beforeEach -> - editor.setSelectedBufferRange([[4, 9],[5, 10]]) + editor.setSelectedBufferRange([[4, 9], [5, 10]]) it "moves above the selection", -> cursor = editor.getLastCursor() @@ -330,7 +330,7 @@ describe "TextEditor", -> editor.moveUp() expect(editor.getCursors()).toEqual [cursor1] - expect(cursor1.getBufferPosition()).toEqual [0,0] + expect(cursor1.getBufferPosition()).toEqual [0, 0] describe "when the cursor was moved down from the beginning of an indented soft-wrapped line", -> it "moves to the beginning of the previous line", -> @@ -396,7 +396,7 @@ describe "TextEditor", -> describe "when there is a selection", -> beforeEach -> - editor.setSelectedBufferRange([[4, 9],[5, 10]]) + editor.setSelectedBufferRange([[4, 9], [5, 10]]) it "moves below the selection", -> cursor = editor.getLastCursor() @@ -410,7 +410,7 @@ describe "TextEditor", -> editor.moveDown() expect(editor.getCursors()).toEqual [cursor1] - expect(cursor1.getBufferPosition()).toEqual [12,2] + expect(cursor1.getBufferPosition()).toEqual [12, 2] describe ".moveLeft()", -> it "moves the cursor by one column to the left", -> @@ -481,7 +481,7 @@ describe "TextEditor", -> describe "when there is a selection", -> beforeEach -> - editor.setSelectedBufferRange([[5, 22],[5, 27]]) + editor.setSelectedBufferRange([[5, 22], [5, 27]]) it "moves to the left of the selection", -> cursor = editor.getLastCursor() @@ -498,7 +498,7 @@ describe "TextEditor", -> [cursor1, cursor2] = editor.getCursors() editor.moveLeft() expect(editor.getCursors()).toEqual [cursor1] - expect(cursor1.getBufferPosition()).toEqual [0,0] + expect(cursor1.getBufferPosition()).toEqual [0, 0] describe ".moveRight()", -> it "moves the cursor by one column to the right", -> @@ -553,7 +553,7 @@ describe "TextEditor", -> describe "when there is a selection", -> beforeEach -> - editor.setSelectedBufferRange([[5, 22],[5, 27]]) + editor.setSelectedBufferRange([[5, 22], [5, 27]]) it "moves to the left of the selection", -> cursor = editor.getLastCursor() @@ -570,23 +570,23 @@ describe "TextEditor", -> editor.moveRight() expect(editor.getCursors()).toEqual [cursor1] - expect(cursor1.getBufferPosition()).toEqual [12,2] + expect(cursor1.getBufferPosition()).toEqual [12, 2] describe ".moveToTop()", -> it "moves the cursor to the top of the buffer", -> - editor.setCursorScreenPosition [11,1] - editor.addCursorAtScreenPosition [12,0] + editor.setCursorScreenPosition [11, 1] + editor.addCursorAtScreenPosition [12, 0] editor.moveToTop() expect(editor.getCursors().length).toBe 1 - expect(editor.getCursorBufferPosition()).toEqual [0,0] + expect(editor.getCursorBufferPosition()).toEqual [0, 0] describe ".moveToBottom()", -> it "moves the cusor to the bottom of the buffer", -> - editor.setCursorScreenPosition [0,0] - editor.addCursorAtScreenPosition [1,0] + editor.setCursorScreenPosition [0, 0] + editor.addCursorAtScreenPosition [1, 0] editor.moveToBottom() expect(editor.getCursors().length).toBe 1 - expect(editor.getCursorBufferPosition()).toEqual [12,2] + expect(editor.getCursorBufferPosition()).toEqual [12, 2] describe ".moveToBeginningOfScreenLine()", -> describe "when soft wrap is on", -> @@ -599,14 +599,14 @@ describe "TextEditor", -> expect(cursor.getScreenPosition()).toEqual [1, 0] describe "when soft wrap is off", -> - it "moves cursor to the beginning of then line", -> - editor.setCursorScreenPosition [0,5] - editor.addCursorAtScreenPosition [1,7] + it "moves cursor to the beginning of the line", -> + editor.setCursorScreenPosition [0, 5] + editor.addCursorAtScreenPosition [1, 7] editor.moveToBeginningOfScreenLine() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,0] - expect(cursor2.getBufferPosition()).toEqual [1,0] + expect(cursor1.getBufferPosition()).toEqual [0, 0] + expect(cursor2.getBufferPosition()).toEqual [1, 0] describe ".moveToEndOfScreenLine()", -> describe "when soft wrap is on", -> @@ -620,13 +620,13 @@ describe "TextEditor", -> describe "when soft wrap is off", -> it "moves cursor to the end of line", -> - editor.setCursorScreenPosition [0,0] - editor.addCursorAtScreenPosition [1,0] + editor.setCursorScreenPosition [0, 0] + editor.addCursorAtScreenPosition [1, 0] editor.moveToEndOfScreenLine() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,29] - expect(cursor2.getBufferPosition()).toEqual [1,30] + expect(cursor1.getBufferPosition()).toEqual [0, 29] + expect(cursor2.getBufferPosition()).toEqual [1, 30] describe ".moveToBeginningOfLine()", -> it "moves cursor to the beginning of the buffer line", -> @@ -651,58 +651,58 @@ describe "TextEditor", -> it "moves to the first character of the current screen line or the beginning of the screen line if it's already on the first character", -> editor.setSoftWrapped(true) editor.setEditorWidthInChars(10) - editor.setCursorScreenPosition [2,5] - editor.addCursorAtScreenPosition [8,7] + editor.setCursorScreenPosition [2, 5] + editor.addCursorAtScreenPosition [8, 7] editor.moveToFirstCharacterOfLine() [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getScreenPosition()).toEqual [2,0] - expect(cursor2.getScreenPosition()).toEqual [8,2] + expect(cursor1.getScreenPosition()).toEqual [2, 0] + expect(cursor2.getScreenPosition()).toEqual [8, 2] editor.moveToFirstCharacterOfLine() - expect(cursor1.getScreenPosition()).toEqual [2,0] - expect(cursor2.getScreenPosition()).toEqual [8,2] + expect(cursor1.getScreenPosition()).toEqual [2, 0] + expect(cursor2.getScreenPosition()).toEqual [8, 2] describe "when soft wrap is off", -> it "moves to the first character of the current line or the beginning of the line if it's already on the first character", -> - editor.setCursorScreenPosition [0,5] - editor.addCursorAtScreenPosition [1,7] + editor.setCursorScreenPosition [0, 5] + editor.addCursorAtScreenPosition [1, 7] editor.moveToFirstCharacterOfLine() [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,0] - expect(cursor2.getBufferPosition()).toEqual [1,2] + expect(cursor1.getBufferPosition()).toEqual [0, 0] + expect(cursor2.getBufferPosition()).toEqual [1, 2] editor.moveToFirstCharacterOfLine() - expect(cursor1.getBufferPosition()).toEqual [0,0] - expect(cursor2.getBufferPosition()).toEqual [1,0] + expect(cursor1.getBufferPosition()).toEqual [0, 0] + expect(cursor2.getBufferPosition()).toEqual [1, 0] it "moves to the beginning of the line if it only contains whitespace ", -> editor.setText("first\n \nthird") - editor.setCursorScreenPosition [1,2] + editor.setCursorScreenPosition [1, 2] editor.moveToFirstCharacterOfLine() cursor = editor.getLastCursor() - expect(cursor.getBufferPosition()).toEqual [1,0] + expect(cursor.getBufferPosition()).toEqual [1, 0] describe "when invisible characters are enabled with soft tabs", -> it "moves to the first character of the current line without being confused by the invisible characters", -> atom.config.set('editor.showInvisibles', true) - editor.setCursorScreenPosition [1,7] + editor.setCursorScreenPosition [1, 7] editor.moveToFirstCharacterOfLine() - expect(editor.getCursorBufferPosition()).toEqual [1,2] + expect(editor.getCursorBufferPosition()).toEqual [1, 2] editor.moveToFirstCharacterOfLine() - expect(editor.getCursorBufferPosition()).toEqual [1,0] + expect(editor.getCursorBufferPosition()).toEqual [1, 0] describe "when invisible characters are enabled with hard tabs", -> it "moves to the first character of the current line without being confused by the invisible characters", -> atom.config.set('editor.showInvisibles', true) buffer.setTextInRange([[1, 0], [1, Infinity]], '\t\t\ta', normalizeLineEndings: false) - editor.setCursorScreenPosition [1,7] + editor.setCursorScreenPosition [1, 7] editor.moveToFirstCharacterOfLine() - expect(editor.getCursorBufferPosition()).toEqual [1,3] + expect(editor.getCursorBufferPosition()).toEqual [1, 3] editor.moveToFirstCharacterOfLine() - expect(editor.getCursorBufferPosition()).toEqual [1,0] + expect(editor.getCursorBufferPosition()).toEqual [1, 0] describe ".moveToBeginningOfWord()", -> it "moves the cursor to the beginning of the word", -> @@ -792,9 +792,9 @@ describe "TextEditor", -> describe ".moveToBeginningOfNextWord()", -> it "moves the cursor before the first character of the next word", -> - editor.setCursorBufferPosition [0,6] - editor.addCursorAtBufferPosition [1,11] - editor.addCursorAtBufferPosition [2,0] + editor.setCursorBufferPosition [0, 6] + editor.addCursorAtBufferPosition [1, 11] + editor.addCursorAtBufferPosition [2, 0] [cursor1, cursor2, cursor3] = editor.getCursors() editor.moveToBeginningOfNextWord() @@ -805,7 +805,7 @@ describe "TextEditor", -> # When the cursor is on whitespace editor.setText("ab cde- ") - editor.setCursorBufferPosition [0,2] + editor.setCursorBufferPosition [0, 2] cursor = editor.getLastCursor() editor.moveToBeginningOfNextWord() @@ -900,15 +900,15 @@ describe "TextEditor", -> describe "addCursorAtScreenPosition(screenPosition)", -> describe "when a cursor already exists at the position", -> it "returns the existing cursor", -> - cursor1 = editor.addCursorAtScreenPosition([0,2]) - cursor2 = editor.addCursorAtScreenPosition([0,2]) + cursor1 = editor.addCursorAtScreenPosition([0, 2]) + cursor2 = editor.addCursorAtScreenPosition([0, 2]) expect(cursor2.marker).toBe cursor1.marker describe "addCursorAtBufferPosition(bufferPosition)", -> describe "when a cursor already exists at the position", -> it "returns the existing cursor", -> - cursor1 = editor.addCursorAtBufferPosition([1,4]) - cursor2 = editor.addCursorAtBufferPosition([1,4]) + cursor1 = editor.addCursorAtBufferPosition([1, 4]) + cursor2 = editor.addCursorAtBufferPosition([1, 4]) expect(cursor2.marker).toBe cursor1.marker describe "autoscroll", -> @@ -1056,28 +1056,28 @@ describe "TextEditor", -> describe ".selectUp/Down/Left/Right()", -> it "expands each selection to its cursor's new location", -> - editor.setSelectedBufferRanges([[[0,9], [0,13]], [[3,16], [3,21]]]) + editor.setSelectedBufferRanges([[[0, 9], [0, 13]], [[3, 16], [3, 21]]]) [selection1, selection2] = editor.getSelections() editor.selectRight() - expect(selection1.getBufferRange()).toEqual [[0,9], [0,14]] - expect(selection2.getBufferRange()).toEqual [[3,16], [3,22]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [0, 14]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [3, 22]] editor.selectLeft() editor.selectLeft() - expect(selection1.getBufferRange()).toEqual [[0,9], [0,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [3,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [0, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [3, 20]] editor.selectDown() - expect(selection1.getBufferRange()).toEqual [[0,9], [1,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [4,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [1, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [4, 20]] editor.selectUp() - expect(selection1.getBufferRange()).toEqual [[0,9], [0,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [3,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [0, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [3, 20]] it "merges selections when they intersect when moving down", -> - editor.setSelectedBufferRanges([[[0,9], [0,13]], [[1,10], [1,20]], [[2,15], [3,25]]]) + editor.setSelectedBufferRanges([[[0, 9], [0, 13]], [[1, 10], [1, 20]], [[2, 15], [3, 25]]]) [selection1, selection2, selection3] = editor.getSelections() editor.selectDown() @@ -1086,7 +1086,7 @@ describe "TextEditor", -> expect(selection1.isReversed()).toBeFalsy() it "merges selections when they intersect when moving up", -> - editor.setSelectedBufferRanges([[[0,9], [0,13]], [[1,10], [1,20]]], reversed: true) + editor.setSelectedBufferRanges([[[0, 9], [0, 13]], [[1, 10], [1, 20]]], reversed: true) [selection1, selection2] = editor.getSelections() editor.selectUp() @@ -1096,7 +1096,7 @@ describe "TextEditor", -> expect(selection1.isReversed()).toBeTruthy() it "merges selections when they intersect when moving left", -> - editor.setSelectedBufferRanges([[[0,9], [0,13]], [[0,13], [1,20]]], reversed: true) + editor.setSelectedBufferRanges([[[0, 9], [0, 13]], [[0, 13], [1, 20]]], reversed: true) [selection1, selection2] = editor.getSelections() editor.selectLeft() @@ -1105,7 +1105,7 @@ describe "TextEditor", -> expect(selection1.isReversed()).toBeTruthy() it "merges selections when they intersect when moving right", -> - editor.setSelectedBufferRanges([[[0,9], [0,14]], [[0,14], [1,20]]]) + editor.setSelectedBufferRanges([[[0, 9], [0, 14]], [[0, 14], [1, 20]]]) [selection1, selection2] = editor.getSelections() editor.selectRight() @@ -1115,24 +1115,24 @@ describe "TextEditor", -> describe "when counts are passed into the selection functions", -> it "expands each selection to its cursor's new location", -> - editor.setSelectedBufferRanges([[[0,9], [0,13]], [[3,16], [3,21]]]) + editor.setSelectedBufferRanges([[[0, 9], [0, 13]], [[3, 16], [3, 21]]]) [selection1, selection2] = editor.getSelections() editor.selectRight(2) - expect(selection1.getBufferRange()).toEqual [[0,9], [0,15]] - expect(selection2.getBufferRange()).toEqual [[3,16], [3,23]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [0, 15]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [3, 23]] editor.selectLeft(3) - expect(selection1.getBufferRange()).toEqual [[0,9], [0,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [3,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [0, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [3, 20]] editor.selectDown(3) - expect(selection1.getBufferRange()).toEqual [[0,9], [3,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [6,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [3, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [6, 20]] editor.selectUp(2) - expect(selection1.getBufferRange()).toEqual [[0,9], [1,12]] - expect(selection2.getBufferRange()).toEqual [[3,16], [4,20]] + expect(selection1.getBufferRange()).toEqual [[0, 9], [1, 12]] + expect(selection2.getBufferRange()).toEqual [[3, 16], [4, 20]] describe ".selectToBufferPosition(bufferPosition)", -> it "expands the last selection to the given position", -> @@ -1205,22 +1205,22 @@ describe "TextEditor", -> describe ".selectToTop()", -> it "selects text from cusor position to the top of the buffer", -> - editor.setCursorScreenPosition [11,2] - editor.addCursorAtScreenPosition [10,0] + editor.setCursorScreenPosition [11, 2] + editor.addCursorAtScreenPosition [10, 0] editor.selectToTop() expect(editor.getCursors().length).toBe 1 - expect(editor.getCursorBufferPosition()).toEqual [0,0] - expect(editor.getLastSelection().getBufferRange()).toEqual [[0,0], [11,2]] + expect(editor.getCursorBufferPosition()).toEqual [0, 0] + expect(editor.getLastSelection().getBufferRange()).toEqual [[0, 0], [11, 2]] expect(editor.getLastSelection().isReversed()).toBeTruthy() describe ".selectToBottom()", -> it "selects text from cusor position to the bottom of the buffer", -> - editor.setCursorScreenPosition [10,0] - editor.addCursorAtScreenPosition [9,3] + editor.setCursorScreenPosition [10, 0] + editor.addCursorAtScreenPosition [9, 3] editor.selectToBottom() expect(editor.getCursors().length).toBe 1 - expect(editor.getCursorBufferPosition()).toEqual [12,2] - expect(editor.getLastSelection().getBufferRange()).toEqual [[9,3], [12,2]] + expect(editor.getCursorBufferPosition()).toEqual [12, 2] + expect(editor.getLastSelection().getBufferRange()).toEqual [[9, 3], [12, 2]] expect(editor.getLastSelection().isReversed()).toBeFalsy() describe ".selectAll()", -> @@ -1230,57 +1230,57 @@ describe "TextEditor", -> describe ".selectToBeginningOfLine()", -> it "selects text from cusor position to beginning of line", -> - editor.setCursorScreenPosition [12,2] - editor.addCursorAtScreenPosition [11,3] + editor.setCursorScreenPosition [12, 2] + editor.addCursorAtScreenPosition [11, 3] editor.selectToBeginningOfLine() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [12,0] - expect(cursor2.getBufferPosition()).toEqual [11,0] + expect(cursor1.getBufferPosition()).toEqual [12, 0] + expect(cursor2.getBufferPosition()).toEqual [11, 0] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[12,0], [12,2]] + expect(selection1.getBufferRange()).toEqual [[12, 0], [12, 2]] expect(selection1.isReversed()).toBeTruthy() - expect(selection2.getBufferRange()).toEqual [[11,0], [11,3]] + expect(selection2.getBufferRange()).toEqual [[11, 0], [11, 3]] expect(selection2.isReversed()).toBeTruthy() describe ".selectToEndOfLine()", -> it "selects text from cusor position to end of line", -> - editor.setCursorScreenPosition [12,0] - editor.addCursorAtScreenPosition [11,3] + editor.setCursorScreenPosition [12, 0] + editor.addCursorAtScreenPosition [11, 3] editor.selectToEndOfLine() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [12,2] - expect(cursor2.getBufferPosition()).toEqual [11,44] + expect(cursor1.getBufferPosition()).toEqual [12, 2] + expect(cursor2.getBufferPosition()).toEqual [11, 44] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[12,0], [12,2]] + expect(selection1.getBufferRange()).toEqual [[12, 0], [12, 2]] expect(selection1.isReversed()).toBeFalsy() - expect(selection2.getBufferRange()).toEqual [[11,3], [11,44]] + expect(selection2.getBufferRange()).toEqual [[11, 3], [11, 44]] expect(selection2.isReversed()).toBeFalsy() describe ".selectLinesContainingCursors()", -> it "selects the entire line (including newlines) at given row", -> editor.setCursorScreenPosition([1, 2]) editor.selectLinesContainingCursors() - expect(editor.getSelectedBufferRange()).toEqual [[1,0], [2,0]] + expect(editor.getSelectedBufferRange()).toEqual [[1, 0], [2, 0]] expect(editor.getSelectedText()).toBe " var sort = function(items) {\n" editor.setCursorScreenPosition([12, 2]) editor.selectLinesContainingCursors() - expect(editor.getSelectedBufferRange()).toEqual [[12,0], [12,2]] + expect(editor.getSelectedBufferRange()).toEqual [[12, 0], [12, 2]] editor.setCursorBufferPosition([0, 2]) editor.selectLinesContainingCursors() editor.selectLinesContainingCursors() - expect(editor.getSelectedBufferRange()).toEqual [[0,0], [2,0]] + expect(editor.getSelectedBufferRange()).toEqual [[0, 0], [2, 0]] it "autoscrolls to the selection", -> editor.setLineHeightInPixels(10) @@ -1298,59 +1298,59 @@ describe "TextEditor", -> describe ".selectToBeginningOfWord()", -> it "selects text from cusor position to beginning of word", -> - editor.setCursorScreenPosition [0,13] - editor.addCursorAtScreenPosition [3,49] + editor.setCursorScreenPosition [0, 13] + editor.addCursorAtScreenPosition [3, 49] editor.selectToBeginningOfWord() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,4] - expect(cursor2.getBufferPosition()).toEqual [3,47] + expect(cursor1.getBufferPosition()).toEqual [0, 4] + expect(cursor2.getBufferPosition()).toEqual [3, 47] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,4], [0,13]] + expect(selection1.getBufferRange()).toEqual [[0, 4], [0, 13]] expect(selection1.isReversed()).toBeTruthy() - expect(selection2.getBufferRange()).toEqual [[3,47], [3,49]] + expect(selection2.getBufferRange()).toEqual [[3, 47], [3, 49]] expect(selection2.isReversed()).toBeTruthy() describe ".selectToEndOfWord()", -> it "selects text from cusor position to end of word", -> - editor.setCursorScreenPosition [0,4] - editor.addCursorAtScreenPosition [3,48] + editor.setCursorScreenPosition [0, 4] + editor.addCursorAtScreenPosition [3, 48] editor.selectToEndOfWord() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,13] - expect(cursor2.getBufferPosition()).toEqual [3,50] + expect(cursor1.getBufferPosition()).toEqual [0, 13] + expect(cursor2.getBufferPosition()).toEqual [3, 50] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,4], [0,13]] + expect(selection1.getBufferRange()).toEqual [[0, 4], [0, 13]] expect(selection1.isReversed()).toBeFalsy() - expect(selection2.getBufferRange()).toEqual [[3,48], [3,50]] + expect(selection2.getBufferRange()).toEqual [[3, 48], [3, 50]] expect(selection2.isReversed()).toBeFalsy() describe ".selectToBeginningOfNextWord()", -> it "selects text from cusor position to beginning of next word", -> - editor.setCursorScreenPosition [0,4] - editor.addCursorAtScreenPosition [3,48] + editor.setCursorScreenPosition [0, 4] + editor.addCursorAtScreenPosition [3, 48] editor.selectToBeginningOfNextWord() expect(editor.getCursors().length).toBe 2 [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,14] - expect(cursor2.getBufferPosition()).toEqual [3,51] + expect(cursor1.getBufferPosition()).toEqual [0, 14] + expect(cursor2.getBufferPosition()).toEqual [3, 51] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,4], [0,14]] + expect(selection1.getBufferRange()).toEqual [[0, 4], [0, 14]] expect(selection1.isReversed()).toBeFalsy() - expect(selection2.getBufferRange()).toEqual [[3,48], [3,51]] + expect(selection2.getBufferRange()).toEqual [[3, 48], [3, 51]] expect(selection2.isReversed()).toBeFalsy() describe ".selectToPreviousWordBoundary()", -> @@ -1364,13 +1364,13 @@ describe "TextEditor", -> expect(editor.getSelections().length).toBe 4 [selection1, selection2, selection3, selection4] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,8], [0,4]] + expect(selection1.getBufferRange()).toEqual [[0, 8], [0, 4]] expect(selection1.isReversed()).toBeTruthy() - expect(selection2.getBufferRange()).toEqual [[2,0], [1,30]] + expect(selection2.getBufferRange()).toEqual [[2, 0], [1, 30]] expect(selection2.isReversed()).toBeTruthy() - expect(selection3.getBufferRange()).toEqual [[3,4], [3,0]] + expect(selection3.getBufferRange()).toEqual [[3, 4], [3, 0]] expect(selection3.isReversed()).toBeTruthy() - expect(selection4.getBufferRange()).toEqual [[3,14], [3,13]] + expect(selection4.getBufferRange()).toEqual [[3, 14], [3, 13]] expect(selection4.isReversed()).toBeTruthy() describe ".selectToNextWordBoundary()", -> @@ -1384,13 +1384,13 @@ describe "TextEditor", -> expect(editor.getSelections().length).toBe 4 [selection1, selection2, selection3, selection4] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,8], [0,13]] + expect(selection1.getBufferRange()).toEqual [[0, 8], [0, 13]] expect(selection1.isReversed()).toBeFalsy() - expect(selection2.getBufferRange()).toEqual [[2,40], [3,0]] + expect(selection2.getBufferRange()).toEqual [[2, 40], [3, 0]] expect(selection2.isReversed()).toBeFalsy() - expect(selection3.getBufferRange()).toEqual [[4,0], [4,4]] + expect(selection3.getBufferRange()).toEqual [[4, 0], [4, 4]] expect(selection3.isReversed()).toBeFalsy() - expect(selection4.getBufferRange()).toEqual [[3,30], [3,31]] + expect(selection4.getBufferRange()).toEqual [[3, 30], [3, 31]] expect(selection4.isReversed()).toBeFalsy() describe ".selectWordsContainingCursors()", -> @@ -1452,27 +1452,27 @@ describe "TextEditor", -> describe ".selectToFirstCharacterOfLine()", -> it "moves to the first character of the current line or the beginning of the line if it's already on the first character", -> - editor.setCursorScreenPosition [0,5] - editor.addCursorAtScreenPosition [1,7] + editor.setCursorScreenPosition [0, 5] + editor.addCursorAtScreenPosition [1, 7] editor.selectToFirstCharacterOfLine() [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,0] - expect(cursor2.getBufferPosition()).toEqual [1,2] + expect(cursor1.getBufferPosition()).toEqual [0, 0] + expect(cursor2.getBufferPosition()).toEqual [1, 2] expect(editor.getSelections().length).toBe 2 [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,0], [0,5]] + expect(selection1.getBufferRange()).toEqual [[0, 0], [0, 5]] expect(selection1.isReversed()).toBeTruthy() - expect(selection2.getBufferRange()).toEqual [[1,2], [1,7]] + expect(selection2.getBufferRange()).toEqual [[1, 2], [1, 7]] expect(selection2.isReversed()).toBeTruthy() editor.selectToFirstCharacterOfLine() [selection1, selection2] = editor.getSelections() - expect(selection1.getBufferRange()).toEqual [[0,0], [0,5]] + expect(selection1.getBufferRange()).toEqual [[0, 0], [0, 5]] expect(selection1.isReversed()).toBeTruthy() - expect(selection2.getBufferRange()).toEqual [[1,0], [1,7]] + expect(selection2.getBufferRange()).toEqual [[1, 0], [1, 7]] expect(selection2.isReversed()).toBeTruthy() describe ".setSelectedBufferRanges(ranges)", -> @@ -1501,7 +1501,7 @@ describe "TextEditor", -> describe "when the 'preserveFolds' option is false (the default)", -> it "removes folds that contain the selections", -> - editor.setSelectedBufferRange([[0,0], [0,0]]) + editor.setSelectedBufferRange([[0, 0], [0, 0]]) editor.createFold(1, 4) editor.createFold(2, 3) editor.createFold(6, 8) @@ -1515,7 +1515,7 @@ describe "TextEditor", -> describe "when the 'preserveFolds' option is true", -> it "does not remove folds that contain the selections", -> - editor.setSelectedBufferRange([[0,0], [0,0]]) + editor.setSelectedBufferRange([[0, 0], [0, 0]]) editor.createFold(1, 4) editor.createFold(6, 8) editor.setSelectedBufferRanges([[[2, 2], [3, 3]], [[6, 0], [6, 1]]], preserveFolds: true) @@ -1965,7 +1965,7 @@ describe "TextEditor", -> describe "when there are multiple non-empty selections", -> describe "when the selections are on the same line", -> it "replaces each selection range with the inserted characters", -> - editor.setSelectedBufferRanges([[[0,4], [0,13]], [[0,22], [0,24]]]) + editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[0, 22], [0, 24]]]) editor.insertText("x") [cursor1, cursor2] = editor.getCursors() @@ -1995,8 +1995,8 @@ describe "TextEditor", -> describe "when there is a selection that ends on a folded line", -> it "destroys the selection", -> - editor.createFold(2,4) - editor.setSelectedBufferRange([[1,0], [2,0]]) + editor.createFold(2, 4) + editor.setSelectedBufferRange([[1, 0], [2, 0]]) editor.insertText('holy cow') expect(editor.tokenizedLineForScreenRow(2).fold).toBeUndefined() @@ -2117,17 +2117,17 @@ describe "TextEditor", -> expect(editor.lineTextForBufferRow(9)).toBe " }" [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [4,0] - expect(cursor2.getBufferPosition()).toEqual [8,0] + expect(cursor1.getBufferPosition()).toEqual [4, 0] + expect(cursor2.getBufferPosition()).toEqual [8, 0] describe ".insertNewlineBelow()", -> describe "when the operation is undone", -> it "places the cursor back at the previous location", -> - editor.setCursorBufferPosition([0,2]) + editor.setCursorBufferPosition([0, 2]) editor.insertNewlineBelow() - expect(editor.getCursorBufferPosition()).toEqual [1,0] + expect(editor.getCursorBufferPosition()).toEqual [1, 0] editor.undo() - expect(editor.getCursorBufferPosition()).toEqual [0,2] + expect(editor.getCursorBufferPosition()).toEqual [0, 2] it "inserts a newline below the cursor's current line, autoindents it, and moves the cursor to the end of the line", -> atom.config.set("editor.autoIndent", true) @@ -2141,48 +2141,48 @@ describe "TextEditor", -> it "inserts a newline on the first line and moves the cursor to the first line", -> editor.setCursorBufferPosition([0]) editor.insertNewlineAbove() - expect(editor.getCursorBufferPosition()).toEqual [0,0] + expect(editor.getCursorBufferPosition()).toEqual [0, 0] expect(editor.lineTextForBufferRow(0)).toBe '' expect(editor.lineTextForBufferRow(1)).toBe 'var quicksort = function () {' expect(editor.buffer.getLineCount()).toBe 14 describe "when the cursor is not on the first line", -> it "inserts a newline above the current line and moves the cursor to the inserted line", -> - editor.setCursorBufferPosition([3,4]) + editor.setCursorBufferPosition([3, 4]) editor.insertNewlineAbove() - expect(editor.getCursorBufferPosition()).toEqual [3,0] + expect(editor.getCursorBufferPosition()).toEqual [3, 0] expect(editor.lineTextForBufferRow(3)).toBe '' expect(editor.lineTextForBufferRow(4)).toBe ' var pivot = items.shift(), current, left = [], right = [];' expect(editor.buffer.getLineCount()).toBe 14 editor.undo() - expect(editor.getCursorBufferPosition()).toEqual [3,4] + expect(editor.getCursorBufferPosition()).toEqual [3, 4] it "indents the new line to the correct level when editor.autoIndent is true", -> atom.config.set('editor.autoIndent', true) editor.setText(' var test') - editor.setCursorBufferPosition([0,2]) + editor.setCursorBufferPosition([0, 2]) editor.insertNewlineAbove() - expect(editor.getCursorBufferPosition()).toEqual [0,2] + expect(editor.getCursorBufferPosition()).toEqual [0, 2] expect(editor.lineTextForBufferRow(0)).toBe ' ' expect(editor.lineTextForBufferRow(1)).toBe ' var test' editor.setText('\n var test') - editor.setCursorBufferPosition([1,2]) + editor.setCursorBufferPosition([1, 2]) editor.insertNewlineAbove() - expect(editor.getCursorBufferPosition()).toEqual [1,2] + expect(editor.getCursorBufferPosition()).toEqual [1, 2] expect(editor.lineTextForBufferRow(0)).toBe '' expect(editor.lineTextForBufferRow(1)).toBe ' ' expect(editor.lineTextForBufferRow(2)).toBe ' var test' editor.setText('function() {\n}') - editor.setCursorBufferPosition([1,1]) + editor.setCursorBufferPosition([1, 1]) editor.insertNewlineAbove() - expect(editor.getCursorBufferPosition()).toEqual [1,2] + expect(editor.getCursorBufferPosition()).toEqual [1, 2] expect(editor.lineTextForBufferRow(0)).toBe 'function() {' expect(editor.lineTextForBufferRow(1)).toBe ' ' expect(editor.lineTextForBufferRow(2)).toBe '}' @@ -2190,7 +2190,7 @@ describe "TextEditor", -> describe "when a new line is appended before a closing tag (e.g. by pressing enter before a selection)", -> it "moves the line down and keeps the indentation level the same when editor.autoIndent is true", -> atom.config.set('editor.autoIndent', true) - editor.setCursorBufferPosition([9,2]) + editor.setCursorBufferPosition([9, 2]) editor.insertNewline() expect(editor.lineTextForBufferRow(10)).toBe ' };' @@ -2240,9 +2240,9 @@ describe "TextEditor", -> describe "when the cursor is on the first column of a line below a fold", -> it "deletes the folded lines", -> - editor.setCursorScreenPosition([4,0]) + editor.setCursorScreenPosition([4, 0]) editor.foldCurrentRow() - editor.setCursorScreenPosition([5,0]) + editor.setCursorScreenPosition([5, 0]) editor.backspace() expect(buffer.lineForRow(4)).toBe " return sort(left).concat(pivot).concat(sort(right));" @@ -2250,9 +2250,9 @@ describe "TextEditor", -> describe "when the cursor is in the middle of a line below a fold", -> it "backspaces as normal", -> - editor.setCursorScreenPosition([4,0]) + editor.setCursorScreenPosition([4, 0]) editor.foldCurrentRow() - editor.setCursorScreenPosition([5,5]) + editor.setCursorScreenPosition([5, 5]) editor.backspace() expect(buffer.lineForRow(7)).toBe " }" @@ -2317,18 +2317,18 @@ describe "TextEditor", -> expect(editor.lineTextForBufferRow(5)).toBe " }" [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [2,40] - expect(cursor2.getBufferPosition()).toEqual [4,30] + expect(cursor1.getBufferPosition()).toEqual [2, 40] + expect(cursor2.getBufferPosition()).toEqual [4, 30] describe "when there is a single selection", -> it "deletes the selection, but not the character before it", -> - editor.setSelectedBufferRange([[0,5], [0,9]]) + editor.setSelectedBufferRange([[0, 5], [0, 9]]) editor.backspace() expect(editor.buffer.lineForRow(0)).toBe 'var qsort = function () {' describe "when the selection ends on a folded line", -> it "preserves the fold", -> - editor.setSelectedBufferRange([[3,0], [4,0]]) + editor.setSelectedBufferRange([[3, 0], [4, 0]]) editor.foldBufferRow(4) editor.backspace() @@ -2337,7 +2337,7 @@ describe "TextEditor", -> describe "when there are multiple selections", -> it "removes all selected text", -> - editor.setSelectedBufferRanges([[[0,4], [0,13]], [[0,16], [0,24]]]) + editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[0, 16], [0, 24]]]) editor.backspace() expect(editor.lineTextForBufferRow(0)).toBe 'var = () {' @@ -2533,8 +2533,8 @@ describe "TextEditor", -> describe "when the cursor is on a folded line", -> it "removes the lines contained by the fold", -> editor.setSelectedBufferRange([[2, 0], [2, 0]]) - editor.createFold(2,4) - editor.createFold(2,6) + editor.createFold(2, 4) + editor.createFold(2, 6) oldLine7 = buffer.lineForRow(7) oldLine8 = buffer.lineForRow(8) @@ -2589,8 +2589,8 @@ describe "TextEditor", -> expect(editor.lineTextForBufferRow(0)).toBe "var quicksort = function () { var sort = function(items) { if (items.length <= 1) return items;" [cursor1, cursor2] = editor.getCursors() - expect(cursor1.getBufferPosition()).toEqual [0,29] - expect(cursor2.getBufferPosition()).toEqual [0,59] + expect(cursor1.getBufferPosition()).toEqual [0, 29] + expect(cursor2.getBufferPosition()).toEqual [0, 59] describe "when there is a single selection", -> it "deletes the selection, but not the character following it", -> @@ -2603,7 +2603,7 @@ describe "TextEditor", -> describe "when there are multiple selections", -> describe "when selections are on the same line", -> it "removes all selected text", -> - editor.setSelectedBufferRanges([[[0,4], [0,13]], [[0,16], [0,24]]]) + editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[0, 16], [0, 24]]]) editor.delete() expect(editor.lineTextForBufferRow(0)).toBe 'var = () {' @@ -2781,9 +2781,9 @@ describe "TextEditor", -> describe "when many selections get added in shuffle order", -> it "cuts them in order", -> editor.setSelectedBufferRanges([ - [[2,8], [2, 13]] - [[0,4], [0,13]], - [[1,6], [1, 10]], + [[2, 8], [2, 13]] + [[0, 4], [0, 13]], + [[1, 6], [1, 10]], ]) editor.cutSelectedText() expect(atom.clipboard.read()).toEqual """ @@ -2813,7 +2813,7 @@ describe "TextEditor", -> describe "when text is selected", -> it "only cuts the selected text, not to the end of the line", -> - editor.setSelectedBufferRanges([[[2,20], [2, 30]], [[3, 20], [3, 20]]]) + editor.setSelectedBufferRanges([[[2, 20], [2, 30]], [[3, 20], [3, 20]]]) editor.cutToEndOfLine() @@ -2823,7 +2823,7 @@ describe "TextEditor", -> describe ".copySelectedText()", -> it "copies selected text onto the clipboard", -> - editor.setSelectedBufferRanges([[[0,4], [0,13]], [[1,6], [1, 10]], [[2,8], [2, 13]]]) + editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[1, 6], [1, 10]], [[2, 8], [2, 13]]]) editor.copySelectedText() expect(buffer.lineForRow(0)).toBe "var quicksort = function () {" @@ -2857,9 +2857,9 @@ describe "TextEditor", -> describe "when many selections get added in shuffle order", -> it "copies them in order", -> editor.setSelectedBufferRanges([ - [[2,8], [2, 13]] - [[0,4], [0,13]], - [[1,6], [1, 10]], + [[2, 8], [2, 13]] + [[0, 4], [0, 13]], + [[1, 6], [1, 10]], ]) editor.copySelectedText() expect(atom.clipboard.read()).toEqual """ @@ -2876,7 +2876,7 @@ describe "TextEditor", -> textEditor.insertText(text) numberOfNewlines = text.match(/\n/g)?.length endColumn = text.match(/[^\n]*$/)[0]?.length - textEditor.getLastSelection().setBufferRange([[0,startColumn], [numberOfNewlines,endColumn]]) + textEditor.getLastSelection().setBufferRange([[0, startColumn], [numberOfNewlines, endColumn]]) textEditor.cutSelectedText() it "pastes text into the buffer", -> @@ -3020,7 +3020,7 @@ describe "TextEditor", -> describe "when nothing is selected", -> describe "when softTabs is enabled", -> it "indents line and retains selection", -> - editor.setSelectedBufferRange([[0,3], [0,3]]) + editor.setSelectedBufferRange([[0, 3], [0, 3]]) editor.indentSelectedRows() expect(buffer.lineForRow(0)).toBe " var quicksort = function () {" expect(editor.getSelectedBufferRange()).toEqual [[0, 3 + editor.getTabLength()], [0, 3 + editor.getTabLength()]] @@ -3029,7 +3029,7 @@ describe "TextEditor", -> it "indents line and retains selection", -> convertToHardTabs(buffer) editor.setSoftTabs(false) - editor.setSelectedBufferRange([[0,3], [0,3]]) + editor.setSelectedBufferRange([[0, 3], [0, 3]]) editor.indentSelectedRows() expect(buffer.lineForRow(0)).toBe "\tvar quicksort = function () {" expect(editor.getSelectedBufferRange()).toEqual [[0, 3 + 1], [0, 3 + 1]] @@ -3037,7 +3037,7 @@ describe "TextEditor", -> describe "when one line is selected", -> describe "when softTabs is enabled", -> it "indents line and retains selection", -> - editor.setSelectedBufferRange([[0,4], [0,14]]) + editor.setSelectedBufferRange([[0, 4], [0, 14]]) editor.indentSelectedRows() expect(buffer.lineForRow(0)).toBe "#{editor.getTabText()}var quicksort = function () {" expect(editor.getSelectedBufferRange()).toEqual [[0, 4 + editor.getTabLength()], [0, 14 + editor.getTabLength()]] @@ -3046,7 +3046,7 @@ describe "TextEditor", -> it "indents line and retains selection", -> convertToHardTabs(buffer) editor.setSoftTabs(false) - editor.setSelectedBufferRange([[0,4], [0,14]]) + editor.setSelectedBufferRange([[0, 4], [0, 14]]) editor.indentSelectedRows() expect(buffer.lineForRow(0)).toBe "\tvar quicksort = function () {" expect(editor.getSelectedBufferRange()).toEqual [[0, 4 + 1], [0, 14 + 1]] @@ -3054,7 +3054,7 @@ describe "TextEditor", -> describe "when multiple lines are selected", -> describe "when softTabs is enabled", -> it "indents selected lines (that are not empty) and retains selection", -> - editor.setSelectedBufferRange([[9,1], [11,15]]) + editor.setSelectedBufferRange([[9, 1], [11, 15]]) editor.indentSelectedRows() expect(buffer.lineForRow(9)).toBe " };" expect(buffer.lineForRow(10)).toBe "" @@ -3062,7 +3062,7 @@ describe "TextEditor", -> expect(editor.getSelectedBufferRange()).toEqual [[9, 1 + editor.getTabLength()], [11, 15 + editor.getTabLength()]] it "does not indent the last row if the selection ends at column 0", -> - editor.setSelectedBufferRange([[9,1], [11,0]]) + editor.setSelectedBufferRange([[9, 1], [11, 0]]) editor.indentSelectedRows() expect(buffer.lineForRow(9)).toBe " };" expect(buffer.lineForRow(10)).toBe "" @@ -3073,7 +3073,7 @@ describe "TextEditor", -> it "indents selected lines (that are not empty) and retains selection", -> convertToHardTabs(buffer) editor.setSoftTabs(false) - editor.setSelectedBufferRange([[9,1], [11,15]]) + editor.setSelectedBufferRange([[9, 1], [11, 15]]) editor.indentSelectedRows() expect(buffer.lineForRow(9)).toBe "\t\t};" expect(buffer.lineForRow(10)).toBe "" @@ -3083,7 +3083,7 @@ describe "TextEditor", -> describe ".outdentSelectedRows()", -> describe "when nothing is selected", -> it "outdents line and retains selection", -> - editor.setSelectedBufferRange([[1,3], [1,3]]) + editor.setSelectedBufferRange([[1, 3], [1, 3]]) editor.outdentSelectedRows() expect(buffer.lineForRow(1)).toBe "var sort = function(items) {" expect(editor.getSelectedBufferRange()).toEqual [[1, 3 - editor.getTabLength()], [1, 3 - editor.getTabLength()]] @@ -3120,14 +3120,14 @@ describe "TextEditor", -> describe "when one line is selected", -> it "outdents line and retains editor", -> - editor.setSelectedBufferRange([[1,4], [1,14]]) + editor.setSelectedBufferRange([[1, 4], [1, 14]]) editor.outdentSelectedRows() expect(buffer.lineForRow(1)).toBe "var sort = function(items) {" expect(editor.getSelectedBufferRange()).toEqual [[1, 4 - editor.getTabLength()], [1, 14 - editor.getTabLength()]] describe "when multiple lines are selected", -> it "outdents selected lines and retains editor", -> - editor.setSelectedBufferRange([[0,1], [3,15]]) + editor.setSelectedBufferRange([[0, 1], [3, 15]]) editor.outdentSelectedRows() expect(buffer.lineForRow(0)).toBe "var quicksort = function () {" expect(buffer.lineForRow(1)).toBe "var sort = function(items) {" @@ -3136,7 +3136,7 @@ describe "TextEditor", -> expect(editor.getSelectedBufferRange()).toEqual [[0, 1], [3, 15 - editor.getTabLength()]] it "does not outdent the last line of the selection if it ends at column 0", -> - editor.setSelectedBufferRange([[0,1], [3,0]]) + editor.setSelectedBufferRange([[0, 1], [3, 0]]) editor.outdentSelectedRows() expect(buffer.lineForRow(0)).toBe "var quicksort = function () {" expect(buffer.lineForRow(1)).toBe "var sort = function(items) {" @@ -3149,7 +3149,7 @@ describe "TextEditor", -> it "auto-indents the selection", -> editor.setCursorBufferPosition([2, 0]) editor.insertText("function() {\ninside=true\n}\n i=1\n") - editor.getLastSelection().setBufferRange([[2,0], [6,0]]) + editor.getLastSelection().setBufferRange([[2, 0], [6, 0]]) editor.autoIndentSelectedRows() expect(editor.lineTextForBufferRow(2)).toBe " function() {" @@ -3385,8 +3385,8 @@ describe "TextEditor", -> expect(editor.getCursors().length).toBe 2 expect(editor.getCursors()).toEqual [cursor1, cursor3] - expect(cursor1.getBufferPosition()).toEqual [0,0] - expect(cursor3.getBufferPosition()).toEqual [1,2] + expect(cursor1.getBufferPosition()).toEqual [0, 0] + expect(cursor3.getBufferPosition()).toEqual [1, 2] describe 'reading text', -> it '.lineTextForScreenRow(row)', -> @@ -3544,7 +3544,7 @@ describe "TextEditor", -> describe "when there is a selection", -> it "upper cases the current selection", -> editor.buffer.setText("abc") - editor.setSelectedBufferRange([[0,0], [0,2]]) + editor.setSelectedBufferRange([[0, 0], [0, 2]]) editor.upperCase() expect(editor.lineTextForBufferRow(0)).toBe 'ABc' expect(editor.getSelectedBufferRange()).toEqual [[0, 0], [0, 2]] @@ -3561,7 +3561,7 @@ describe "TextEditor", -> describe "when there is a selection", -> it "lower cases the current selection", -> editor.buffer.setText("ABC") - editor.setSelectedBufferRange([[0,0], [0,2]]) + editor.setSelectedBufferRange([[0, 0], [0, 2]]) editor.lowerCase() expect(editor.lineTextForBufferRow(0)).toBe 'abC' expect(editor.getSelectedBufferRange()).toEqual [[0, 0], [0, 2]] @@ -3652,7 +3652,7 @@ describe "TextEditor", -> it "preserves the current cursor position", -> editor.setCursorScreenPosition([0, 1]) editor.buffer.reload() - expect(editor.getCursorScreenPosition()).toEqual [0,1] + expect(editor.getCursorScreenPosition()).toEqual [0, 1] describe "when a better-matched grammar is added to syntax", -> it "switches to the better-matched grammar and re-tokenizes the buffer", -> @@ -4235,28 +4235,28 @@ describe "TextEditor", -> editor.selectPageDown() expect(editor.getScrollTop()).toBe 30 - expect(editor.getSelectedBufferRanges()).toEqual [[[0,0], [5,0]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [5, 0]]] editor.selectPageDown() expect(editor.getScrollTop()).toBe 80 - expect(editor.getSelectedBufferRanges()).toEqual [[[0,0], [10,0]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [10, 0]]] editor.selectPageDown() expect(editor.getScrollTop()).toBe 80 - expect(editor.getSelectedBufferRanges()).toEqual [[[0,0], [12,2]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [12, 2]]] editor.moveToBottom() editor.selectPageUp() expect(editor.getScrollTop()).toBe 50 - expect(editor.getSelectedBufferRanges()).toEqual [[[7,0], [12,2]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[7, 0], [12, 2]]] editor.selectPageUp() expect(editor.getScrollTop()).toBe 0 - expect(editor.getSelectedBufferRanges()).toEqual [[[2,0], [12,2]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[2, 0], [12, 2]]] editor.selectPageUp() expect(editor.getScrollTop()).toBe 0 - expect(editor.getSelectedBufferRanges()).toEqual [[[0,0], [12,2]]] + expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [12, 2]]] describe '.get/setPlaceholderText()', -> it 'can be created with placeholderText', -> diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 45cc03a44..dc57d3fee 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -287,7 +287,7 @@ describe "TokenizedBuffer", -> describe "when there is an insertion that is larger than the chunk size", -> it "tokenizes the initial chunk synchronously, then tokenizes the remaining lines in the background", -> commentBlock = _.multiplyString("// a comment\n", tokenizedBuffer.chunkSize + 2) - buffer.insert([0,0], commentBlock) + buffer.insert([0, 0], commentBlock) expect(tokenizedBuffer.tokenizedLineForRow(0).ruleStack?).toBeTruthy() expect(tokenizedBuffer.tokenizedLineForRow(4).ruleStack?).toBeTruthy() expect(tokenizedBuffer.tokenizedLineForRow(5).ruleStack?).toBeFalsy() @@ -541,7 +541,7 @@ describe "TokenizedBuffer", -> runs -> fullyTokenize(tokenizedBuffer) {tokens} = tokenizedBuffer.tokenizedLineForRow(0) - expect(tokens[0]).toEqual value: '<', scopes: ["text.html.ruby","meta.tag.block.any.html","punctuation.definition.tag.begin.html"] + expect(tokens[0]).toEqual value: '<', scopes: ["text.html.ruby", "meta.tag.block.any.html", "punctuation.definition.tag.begin.html"] describe ".tokenForPosition(position)", -> afterEach -> @@ -552,9 +552,9 @@ describe "TokenizedBuffer", -> buffer = atom.project.bufferForPathSync('sample.js') tokenizedBuffer = new TokenizedBuffer({buffer}) fullyTokenize(tokenizedBuffer) - expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"] - expect(tokenizedBuffer.tokenForPosition([1,1]).scopes).toEqual ["source.js"] - expect(tokenizedBuffer.tokenForPosition([1,2]).scopes).toEqual ["source.js", "storage.modifier.js"] + expect(tokenizedBuffer.tokenForPosition([1, 0]).scopes).toEqual ["source.js"] + expect(tokenizedBuffer.tokenForPosition([1, 1]).scopes).toEqual ["source.js"] + expect(tokenizedBuffer.tokenForPosition([1, 2]).scopes).toEqual ["source.js", "storage.modifier.js"] describe ".bufferRangeForScopeAtPosition(selector, position)", -> beforeEach -> @@ -572,7 +572,7 @@ describe "TokenizedBuffer", -> describe "when the selector matches a run of multiple tokens at the position", -> it "returns the range covered by all contigous tokens (within a single line)", -> - expect(tokenizedBuffer.bufferRangeForScopeAtPosition('.meta.function', [1, 18])).toEqual [[1, 6], [1, 28]] + expect(tokenizedBuffer.bufferRangeForScopeAtPosition('.function', [1, 18])).toEqual [[1, 6], [1, 28]] describe "when the editor.tabLength config value changes", -> it "updates the tab length of the tokenized lines", -> @@ -580,20 +580,20 @@ describe "TokenizedBuffer", -> buffer.setText('\ttest') tokenizedBuffer = new TokenizedBuffer({buffer}) fullyTokenize(tokenizedBuffer) - expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' ' atom.config.set('editor.tabLength', 6) - expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' ' it "does not allow the tab length to be less than 1", -> buffer = atom.project.bufferForPathSync('sample.js') buffer.setText('\ttest') tokenizedBuffer = new TokenizedBuffer({buffer}) fullyTokenize(tokenizedBuffer) - expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' ' atom.config.set('editor.tabLength', 1) - expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' ' atom.config.set('editor.tabLength', 0) - expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' ' describe "when the invisibles value changes", -> beforeEach -> diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 0b32ff31f..009f95a1c 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -1027,7 +1027,7 @@ describe "Workspace", -> atom.project.open('sample.js').then (o) -> editor = o runs -> - editor.buffer.setTextInRange([[0,0],[0,0]], 'omg') + editor.buffer.setTextInRange([[0, 0], [0, 0]], 'omg') expect(editor.isModified()).toBeTruthy() waitsForPromise -> diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index d81660a49..ae56fb1d4 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -99,12 +99,12 @@ class AtomApplication # Public: Removes the {AtomWindow} from the global window list. removeWindow: (window) -> - @windows.splice @windows.indexOf(window), 1 - if @windows.length is 0 + if @windows.length is 1 @applicationMenu?.enableWindowSpecificItems(false) if process.platform in ['win32', 'linux'] app.quit() return + @windows.splice(@windows.indexOf(window), 1) @saveState() unless window.isSpec or @quitting # Public: Adds the {AtomWindow} to the global window list. @@ -174,7 +174,7 @@ class AtomApplication @on 'application:open-safe', -> @promptForPathToOpen('all', safeMode: true) @on 'application:open-api-preview', -> @promptForPathToOpen('all', apiPreviewMode: true) @on 'application:open-dev-api-preview', -> @promptForPathToOpen('all', {apiPreviewMode: true, devMode: true}) - @on 'application:inspect', ({x,y, atomWindow}) -> + @on 'application:inspect', ({x, y, atomWindow}) -> atomWindow ?= @focusedWindow() atomWindow?.browserWindow.inspectElement(x, y) @@ -210,6 +210,7 @@ class AtomApplication @openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md')) app.on 'before-quit', => + @saveState() if @hasEditorWindows() @quitting = true app.on 'will-quit', => @@ -217,7 +218,7 @@ class AtomApplication @deleteSocketFile() app.on 'will-exit', => - @saveState() unless @windows.every (window) -> window.isSpec + @saveState() if @hasEditorWindows() @killAllProcesses() @deleteSocketFile() @@ -435,6 +436,9 @@ class AtomApplication states.push(initialPaths: loadSettings.initialPaths) @storageFolder.store('application.json', states) + hasEditorWindows: -> + @windows.some (window) -> not window.isSpec + loadState: -> if (states = @storageFolder.load('application.json'))?.length > 0 for state in states diff --git a/src/config-schema.coffee b/src/config-schema.coffee index 548b35fa8..b814e21de 100644 --- a/src/config-schema.coffee +++ b/src/config-schema.coffee @@ -139,12 +139,14 @@ module.exports = softWrap: type: 'boolean' default: false + description: 'Wraps lines that exceed the width of the window. When `Soft Wrap At Preferred Line Length` is set, it will wrap to the number of characters defined by the `Preferred Line Length` setting.' softTabs: type: 'boolean' default: true softWrapAtPreferredLineLength: type: 'boolean' default: false + description: 'Will wrap to the number of characters defined by the `Preferred Line Length` setting. This will only take effect when soft wrap is enabled globally or for the current language.' softWrapHangingIndent: type: 'integer' default: 0 diff --git a/src/cursor.coffee b/src/cursor.coffee index b54cc6bcd..0681e51ca 100644 --- a/src/cursor.coffee +++ b/src/cursor.coffee @@ -333,7 +333,7 @@ class Cursor extends Model # Public: Moves the cursor to the top of the buffer. moveToTop: -> - @setBufferPosition([0,0]) + @setBufferPosition([0, 0]) # Public: Moves the cursor to the bottom of the buffer. moveToBottom: -> @@ -673,9 +673,9 @@ class Cursor extends Model start = @getBufferPosition() {row, column} = start - scanRange = [[row-1, column], [0,0]] + scanRange = [[row-1, column], [0, 0]] position = new Point(0, 0) - zero = new Point(0,0) + zero = new Point(0, 0) @editor.backwardsScanInBufferRange /^\n*$/g, scanRange, ({range, stop}) -> unless range.start.isEqual(zero) position = range.start diff --git a/src/menu-manager.coffee b/src/menu-manager.coffee index b5c9a80e3..b138f2da2 100644 --- a/src/menu-manager.coffee +++ b/src/menu-manager.coffee @@ -63,6 +63,7 @@ class MenuManager @pendingUpdateOperation = null @template = [] atom.keymaps.onDidLoadBundledKeymaps => @loadPlatformItems() + atom.keymaps.onDidReloadKeymap => @update() atom.packages.onDidActivateInitialPackages => @sortPackagesMenu() # Public: Adds the given items to the application menu. @@ -139,10 +140,19 @@ class MenuManager update: -> clearImmediate(@pendingUpdateOperation) if @pendingUpdateOperation? @pendingUpdateOperation = setImmediate => - keystrokesByCommand = {} + includedBindings = [] + unsetKeystrokes = new Set + for binding in atom.keymaps.getKeyBindings() when @includeSelector(binding.selector) + includedBindings.push(binding) + if binding.command is 'unset!' + unsetKeystrokes.add(binding.keystrokes) + + keystrokesByCommand = {} + for binding in includedBindings when not unsetKeystrokes.has(binding.keystrokes) keystrokesByCommand[binding.command] ?= [] keystrokesByCommand[binding.command].unshift binding.keystrokes + @sendToBrowserProcess(@template, keystrokesByCommand) loadPlatformItems: -> diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index f8f6de6bf..ac71da748 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -309,8 +309,7 @@ class TextEditorComponent selectedLength = inputNode.selectionEnd - inputNode.selectionStart @editor.selectLeft() if selectedLength is 1 - insertedRange = @editor.transact atom.config.get('editor.undoGroupingInterval'), => - @editor.insertText(event.data) + insertedRange = @editor.insertText(event.data, groupUndo: true) inputNode.value = event.data if insertedRange onVerticalScroll: (scrollTop) => diff --git a/src/text-editor-view.coffee b/src/text-editor-view.coffee index ffb59cc66..4d513c6f8 100644 --- a/src/text-editor-view.coffee +++ b/src/text-editor-view.coffee @@ -120,14 +120,14 @@ class TextEditorView extends View getEditor: -> @model - Object.defineProperty @::, 'lineHeight', get: -> @model.getLineHeightInPixels() - Object.defineProperty @::, 'charWidth', get: -> @model.getDefaultCharWidth() - Object.defineProperty @::, 'firstRenderedScreenRow', get: -> @component.getRenderedRowRange()[0] - Object.defineProperty @::, 'lastRenderedScreenRow', get: -> @component.getRenderedRowRange()[1] - Object.defineProperty @::, 'active', get: -> @is(@getPaneView()?.activeView) - Object.defineProperty @::, 'isFocused', get: -> document.activeElement is @element or document.activeElement is @element.component?.hiddenInputComponent?.getDomNode() - Object.defineProperty @::, 'mini', get: -> @model?.isMini() - Object.defineProperty @::, 'component', get: -> @element?.component + Object.defineProperty @prototype, 'lineHeight', get: -> @model.getLineHeightInPixels() + Object.defineProperty @prototype, 'charWidth', get: -> @model.getDefaultCharWidth() + Object.defineProperty @prototype, 'firstRenderedScreenRow', get: -> @component.getRenderedRowRange()[0] + Object.defineProperty @prototype, 'lastRenderedScreenRow', get: -> @component.getRenderedRowRange()[1] + Object.defineProperty @prototype, 'active', get: -> @is(@getPaneView()?.activeView) + Object.defineProperty @prototype, 'isFocused', get: -> document.activeElement is @element or document.activeElement is @element.component?.hiddenInputComponent?.getDomNode() + Object.defineProperty @prototype, 'mini', get: -> @model?.isMini() + Object.defineProperty @prototype, 'component', get: -> @element?.component afterAttach: (onDom) -> return unless onDom diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 4489d82af..6d979fdf7 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -761,15 +761,23 @@ class TextEditor extends Model @emit('will-insert-text', willInsertEvent) if includeDeprecatedAPIs @emitter.emit 'will-insert-text', willInsertEvent + groupingInterval = if options.groupUndo + atom.config.get('editor.undoGroupingInterval') + else + 0 + if willInsert options.autoIndentNewline ?= @shouldAutoIndent() options.autoDecreaseIndent ?= @shouldAutoIndent() - @mutateSelectedText (selection) => - range = selection.insertText(text, options) - didInsertEvent = {text, range} - @emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs - @emitter.emit 'did-insert-text', didInsertEvent - range + @mutateSelectedText( + (selection) => + range = selection.insertText(text, options) + didInsertEvent = {text, range} + @emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs + @emitter.emit 'did-insert-text', didInsertEvent + range + , groupingInterval + ) else false @@ -795,9 +803,9 @@ class TextEditor extends Model # * `fn` A {Function} that will be called once for each {Selection}. The first # argument will be a {Selection} and the second argument will be the # {Number} index of that selection. - mutateSelectedText: (fn) -> + mutateSelectedText: (fn, groupingInterval=0) -> @mergeIntersectingSelections => - @transact => + @transact groupingInterval, => fn(selection, index) for selection, index in @getSelectionsOrderedByBufferPosition() # Move lines intersection the most recent selection up by one row in screen diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 60ebe16f0..55d2e7e37 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -426,7 +426,6 @@ class TokenizedBuffer extends Model new Point(row, column) bufferRangeForScopeAtPosition: (selector, position) -> - selector = new ScopeSelector(selector.replace(/^\./, '')) position = Point.fromObject(position) {openScopes, tags} = @tokenizedLines[position.row] @@ -446,7 +445,8 @@ class TokenizedBuffer extends Model else startColumn = endColumn - return unless selector.matches(scopes) + + return unless selectorMatchesAnyScope(selector, scopes) startScopes = scopes.slice() for startTokenIndex in [(tokenIndex - 1)..0] by -1 @@ -457,7 +457,7 @@ class TokenizedBuffer extends Model else startScopes.push(atom.grammars.scopeForId(tag)) else - break unless selector.matches(startScopes) + break unless selectorMatchesAnyScope(selector, startScopes) startColumn -= tag endScopes = scopes.slice() @@ -469,7 +469,7 @@ class TokenizedBuffer extends Model else endScopes.pop() else - break unless selector.matches(endScopes) + break unless selectorMatchesAnyScope(selector, endScopes) endColumn += tag new Range(new Point(position.row, startColumn), new Point(position.row, endColumn)) @@ -504,3 +504,9 @@ if Grim.includeDeprecatedAPIs Grim.deprecate("TokenizedBuffer::on is deprecated. Use event subscription methods instead.") EmitterMixin::on.apply(this, arguments) + +selectorMatchesAnyScope = (selector, scopes) -> + targetClasses = selector.replace(/^\./, '').split('.') + _.any scopes, (scope) -> + scopeClasses = scope.split('.') + _.isSubset(targetClasses, scopeClasses) diff --git a/src/tooltip-manager.coffee b/src/tooltip-manager.coffee index ee2054b5a..3c9777123 100644 --- a/src/tooltip-manager.coffee +++ b/src/tooltip-manager.coffee @@ -57,9 +57,10 @@ class TooltipManager # Essential: Add a tooltip to the given element. # # * `target` An `HTMLElement` - # * `options` See http://getbootstrap.com/javascript/#tooltips for a full list - # of options. You can also supply the following additional options: - # * `title` {String} Text in the tip. + # * `options` See http://getbootstrap.com/javascript/#tooltips-options for a + # full list of options. You can also supply the following additional options: + # * `title` A {String} or {Function} to use for the text in the tip. If + # given a function, `this` will be set to the `target` element. # * `keyBindingCommand` A {String} containing a command name. If you specify # this option and a key binding exists that matches the command, it will # be appended to the title or rendered alone if no title is specified. diff --git a/src/workspace.coffee b/src/workspace.coffee index 0e6fb7e40..0285cf99d 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -377,7 +377,7 @@ class Workspace extends Model # Open Atom's license in the active pane. openLicense: -> - @open(join(atom.getLoadSettings().resourcePath, 'LICENSE.md')) + @open(path.join(process.resourcesPath, 'LICENSE.md')) # Synchronously open the given URI in the active pane. **Only use this method # in specs. Calling this in production code will block the UI thread and diff --git a/static/bootstrap-overrides.less b/static/bootstrap-overrides.less index df61c0171..115f672f2 100644 --- a/static/bootstrap-overrides.less +++ b/static/bootstrap-overrides.less @@ -32,3 +32,10 @@ body { font-family: @font-family; font-size: @font-size; } + +// disable some styling, will be styled in themes +kbd { + color: inherit; + background-color: none; + box-shadow: none; +}