diff --git a/package.json b/package.json index 75e2a325d..795ee2bc6 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,12 @@ "delegato": "^1", "emissary": "^1.3.3", "event-kit": "^1.0.3", - "first-mate": "^3.0.0", + "first-mate": "^3.0.1", "fs-plus": "^2.6", "fstream": "0.1.24", "fuzzaldrin": "^2.1", "git-utils": "^3.0.0", - "grim": "1.2", + "grim": "1.2.1", "jasmine-json": "~0.0", "jasmine-tagged": "^1.1.4", "jquery": "^2.1.1", @@ -64,9 +64,9 @@ "space-pen": "3.8.2", "stacktrace-parser": "0.1.1", "temp": "0.8.1", - "text-buffer": "^5.1.0", + "text-buffer": "^5.1.1", "theorist": "^1.0.2", - "typescript-simple": "^1.0.0", + "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6" }, "packageDependencies": { @@ -82,7 +82,7 @@ "one-light-ui": "0.4.0", "solarized-dark-syntax": "0.32.0", "solarized-light-syntax": "0.19.0", - "archive-view": "0.53.0", + "archive-view": "0.55.0", "autocomplete": "0.44.0", "autoflow": "0.22.0", "autosave": "0.20.0", @@ -102,7 +102,7 @@ "grammar-selector": "0.46.0", "image-view": "0.54.0", "incompatible-packages": "0.24.0", - "keybinding-resolver": "0.29.0", + "keybinding-resolver": "0.30.0", "link": "0.30.0", "markdown-preview": "0.146.0", "metrics": "0.45.0", @@ -123,7 +123,7 @@ "welcome": "0.26.0", "whitespace": "0.29.0", "wrap-guide": "0.31.0", - "language-c": "0.42.0", + "language-c": "0.43.0", "language-clojure": "0.13.0", "language-coffee-script": "0.39.0", "language-csharp": "0.5.0", diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 93460f173..b5858007e 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -724,6 +724,21 @@ describe "DisplayBuffer", -> expect(displayBuffer.clipScreenPosition([0, 1], clip: 'forward')).toEqual [0, tabLength] expect(displayBuffer.clipScreenPosition([0, tabLength], clip: 'forward')).toEqual [0, tabLength] + describe "::screenPositionForPixelPosition(pixelPosition)", -> + it "clips pixel positions above buffer start", -> + displayBuffer.setLineHeightInPixels(20) + expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0] + expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0] + expect(displayBuffer.screenPositionForPixelPosition(top: -1, left: Infinity)).toEqual [0, 0] + expect(displayBuffer.screenPositionForPixelPosition(top: 0, left: Infinity)).toEqual [0, 29] + + it "clips pixel positions below buffer end", -> + displayBuffer.setLineHeightInPixels(20) + expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2] + expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2] + expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() + 1, left: 0)).toEqual [12, 2] + expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() - 1, left: 0)).toEqual [12, 0] + describe "::screenPositionForBufferPosition(bufferPosition, options)", -> it "clips the specified buffer position", -> expect(displayBuffer.screenPositionForBufferPosition([0, 2])).toEqual [0, 2] diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 5f9d2af2f..a5ca4c309 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -1419,6 +1419,22 @@ describe "TextEditorComponent", -> beforeEach -> linesNode = componentNode.querySelector('.lines') + describe "when the mouse is single-clicked above the first line", -> + it "moves the cursor to the start of file buffer position", -> + editor.setText('foo') + editor.setCursorBufferPosition([0, 3]) + height = 4.5 * lineHeightInPixels + wrapperNode.style.height = height + 'px' + wrapperNode.style.width = 10 * charWidth + 'px' + component.measureDimensions() + nextAnimationFrame() + + coordinates = clientCoordinatesForScreenPosition([0, 2]) + coordinates.clientY = -1 + linesNode.dispatchEvent(buildMouseEvent('mousedown', coordinates)) + nextAnimationFrame() + expect(editor.getCursorScreenPosition()).toEqual [0, 0] + describe "when the mouse is single-clicked below the last line", -> it "moves the cursor to the end of file buffer position", -> editor.setText('foo') diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index bdb6b38fc..51226a22b 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -2730,6 +2730,20 @@ 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]], + ]) + editor.cutSelectedText() + expect(atom.clipboard.read()).toEqual """ + quicksort + sort + items + """ + describe ".cutToEndOfLine()", -> describe "when soft wrap is on", -> it "cuts up to the end of the line", -> @@ -2792,6 +2806,20 @@ describe "TextEditor", -> [[5, 8], [5, 8]] ]) + 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]], + ]) + editor.copySelectedText() + expect(atom.clipboard.read()).toEqual """ + quicksort + sort + items + """ + describe ".pasteText()", -> copyText = (text, {startColumn, textEditor}={}) -> startColumn ?= 0 @@ -2886,8 +2914,12 @@ describe "TextEditor", -> editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[1, 6], [1, 10]]]) editor.copySelectedText() - it "pastes each selection separately into the buffer", -> - editor.copySelectedText() + it "pastes each selection in order separately into the buffer", -> + editor.setSelectedBufferRanges([ + [[1, 6], [1, 10]] + [[0, 4], [0, 13]], + ]) + editor.moveRight() editor.insertText("_") editor.pasteText() diff --git a/src/atom.coffee b/src/atom.coffee index 95ed0d4c9..f05ce11f6 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -768,7 +768,7 @@ class Atom extends Model callback(showSaveDialogSync()) showSaveDialogSync: (defaultPath) -> - defaultPath ?= @project?.getPath() + defaultPath ?= @project?.getPaths()[0] currentWindow = @getCurrentWindow() dialog = remote.require('dialog') dialog.showSaveDialog currentWindow, {title: 'Save File', defaultPath} diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index 3ee0fce3d..358390889 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -33,6 +33,10 @@ class AutoUpdateManager else autoUpdater = require 'auto-updater' + autoUpdater.on 'error', (event, message) => + @setState(ErrorState) + console.error "Error Downloading Update: #{message}" + autoUpdater.setFeedUrl @feedUrl autoUpdater.on 'checking-for-update', => @@ -44,10 +48,6 @@ class AutoUpdateManager autoUpdater.on 'update-available', => @setState(DownladingState) - autoUpdater.on 'error', (event, message) => - @setState(ErrorState) - console.error "Error Downloading Update: #{message}" - autoUpdater.on 'update-downloaded', (event, releaseNotes, @releaseVersion) => @setState(UpdateAvailableState) @emitUpdateAvailableEvent(@getWindows()...) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index b60113661..6ec4ce859 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -692,6 +692,7 @@ class DisplayBuffer extends Model targetLeft = pixelPosition.left defaultCharWidth = @defaultCharWidth row = Math.floor(targetTop / @getLineHeightInPixels()) + targetLeft = 0 if row < 0 targetLeft = Infinity if row > @getLastRow() row = Math.min(row, @getLastRow()) row = Math.max(0, row) diff --git a/src/grammar-registry.coffee b/src/grammar-registry.coffee index acdc863bc..911ffafbe 100644 --- a/src/grammar-registry.coffee +++ b/src/grammar-registry.coffee @@ -2,6 +2,7 @@ _ = require 'underscore-plus' {deprecate} = require 'grim' {specificity} = require 'clear-cut' {Subscriber} = require 'emissary' +{Emitter} = require 'event-kit' FirstMate = require 'first-mate' {ScopeSelector} = FirstMate ScopedPropertyStore = require 'scoped-property-store' @@ -69,3 +70,7 @@ class GrammarRegistry extends FirstMate.GrammarRegistry propertiesForScope: (scope, keyPath) -> deprecate 'Use atom.config.getAll instead.' atom.config.settingsForScopeDescriptor(scope, keyPath) + + clearObservers: -> + @off() + @emitter = new Emitter diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 355a644b8..548725cf6 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -843,7 +843,7 @@ class TextEditor extends Model mutateSelectedText: (fn) -> @mergeIntersectingSelections => @transact => - fn(selection, index) for selection, index in @getSelections() + fn(selection, index) for selection, index in @getSelectionsOrderedByBufferPosition() # Move lines intersection the most recent selection up by one row in screen # coordinates. @@ -2621,7 +2621,7 @@ class TextEditor extends Model # Essential: For each selection, copy the selected text. copySelectedText: -> maintainClipboard = false - for selection in @getSelections() + for selection in @getSelectionsOrderedByBufferPosition() if selection.isEmpty() previousRange = selection.getBufferRange() selection.selectLine()