From 4a864e79dca09f911bde74a2daf3bf321cdad0b0 Mon Sep 17 00:00:00 2001 From: Jesse Grosjean Date: Mon, 30 Mar 2015 13:05:45 -0400 Subject: [PATCH 01/17] Fix screenPositionForPixelPosition for case above first row. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently screenPositionForPixelPosition special cases pixel positions below the last row so that the column position is always set to the last column of the last line, even if the pixel 'x' position is less then that column. This patch special cases picks above the first row so that the text column position will be in the first column even if the pixel 'x' position is greater then that column. At a higher level, this patch fixes the problem where you can’t select to the start of a text field by just clicking and dragging up. Instead you have to click and drag back (x axis) beyond the start of the text field. --- src/display-buffer.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index b60113661..d79b1bce7 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 = -Infinity if row < 0 targetLeft = Infinity if row > @getLastRow() row = Math.min(row, @getLastRow()) row = Math.max(0, row) From b067a6175fe4f854b47499658f2d4cade4fd065f Mon Sep 17 00:00:00 2001 From: Jesse Grosjean Date: Mon, 30 Mar 2015 13:50:25 -0400 Subject: [PATCH 02/17] add screenPositionForPixelPosition spec --- spec/display-buffer-spec.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 93460f173..5ece19692 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -724,6 +724,15 @@ 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 "pixel positions above buffer to map to start", -> + expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0] + expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0] + + it "pixel positions below buffer map to end", -> + expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2] + expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2] + describe "::screenPositionForBufferPosition(bufferPosition, options)", -> it "clips the specified buffer position", -> expect(displayBuffer.screenPositionForBufferPosition([0, 2])).toEqual [0, 2] From 409775b53edaa6081b85cbd5c75e66df13566b8e Mon Sep 17 00:00:00 2001 From: Jesse Grosjean Date: Wed, 1 Apr 2015 12:39:22 -0400 Subject: [PATCH 03/17] Improved specs for clipping pixel positions above/below display buffer --- spec/display-buffer-spec.coffee | 10 ++++++++-- spec/text-editor-component-spec.coffee | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 5ece19692..b5858007e 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -725,13 +725,19 @@ describe "DisplayBuffer", -> expect(displayBuffer.clipScreenPosition([0, tabLength], clip: 'forward')).toEqual [0, tabLength] describe "::screenPositionForPixelPosition(pixelPosition)", -> - it "pixel positions above buffer to map to start", -> + 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 "pixel positions below buffer map to end", -> + 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", -> diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 656dca0f0..df1fbcfbf 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -1559,6 +1559,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.measureHeightAndWidth() + 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') From 44d88e082c6771f68804cf9e762b46664877b0e0 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 2 Apr 2015 16:28:22 +0200 Subject: [PATCH 04/17] :bug: Always copy selections in order --- spec/text-editor-spec.coffee | 14 ++++++++++++++ src/text-editor.coffee | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index bdb6b38fc..0caf62ada 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -2792,6 +2792,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 diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 355a644b8..d3b8200ab 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -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() From b3bdad084f400eb4ab010b7e138c417e9b57e705 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 2 Apr 2015 16:35:26 +0200 Subject: [PATCH 05/17] Always mutate selections in order --- spec/text-editor-spec.coffee | 22 ++++++++++++++++++++-- src/text-editor.coffee | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 0caf62ada..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", -> @@ -2900,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/text-editor.coffee b/src/text-editor.coffee index d3b8200ab..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. From 0fe1ea1af3c93a19affc9a35ad2a169849d72fd8 Mon Sep 17 00:00:00 2001 From: Jesse Grosjean Date: Thu, 2 Apr 2015 12:25:16 -0400 Subject: [PATCH 06/17] Target 0 instead of -Infinity to make the code a bit clearer. --- src/display-buffer.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index d79b1bce7..6ec4ce859 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -692,7 +692,7 @@ class DisplayBuffer extends Model targetLeft = pixelPosition.left defaultCharWidth = @defaultCharWidth row = Math.floor(targetTop / @getLineHeightInPixels()) - targetLeft = -Infinity if row < 0 + targetLeft = 0 if row < 0 targetLeft = Infinity if row > @getLastRow() row = Math.min(row, @getLastRow()) row = Math.max(0, row) From cd8536d8a0d44df4574bad8ed5c3e2d99f9f5513 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 09:42:49 -0700 Subject: [PATCH 07/17] Listen for error event before any other calls --- src/browser/auto-update-manager.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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()...) From 1b8337e79f3cf9837f401209b648b6f702963177 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 09:47:20 -0700 Subject: [PATCH 08/17] Project::getPath -> Project::getPaths Closes atom/autocomplete-css#4 --- src/atom.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index 707500479..a71adeeeb 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} From bc4ed8a874e160e3691a63296152ad34203cbe3e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 10:01:49 -0700 Subject: [PATCH 09/17] :arrow_up: first-mate@3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75e2a325d..e53f93ea6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "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", From 21df0d0401a33a3589ddacd4c2d6c2f067315ef0 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 2 Apr 2015 19:06:41 +0200 Subject: [PATCH 10/17] :white_check_mark: Use component.measureDimensions() --- spec/text-editor-component-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 4b5a503bc..a5ca4c309 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -1426,7 +1426,7 @@ describe "TextEditorComponent", -> height = 4.5 * lineHeightInPixels wrapperNode.style.height = height + 'px' wrapperNode.style.width = 10 * charWidth + 'px' - component.measureHeightAndWidth() + component.measureDimensions() nextAnimationFrame() coordinates = clientCoordinatesForScreenPosition([0, 2]) From 15091c716db2e279e8b6434d799556f69de9cd87 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 10:16:18 -0700 Subject: [PATCH 11/17] Pin to typescript-simple@1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e53f93ea6..2b15919e9 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "temp": "0.8.1", "text-buffer": "^5.1.0", "theorist": "^1.0.2", - "typescript-simple": "^1.0.0", + "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6" }, "packageDependencies": { From ede6dbb581044e5e6e53ec9eedd912c6ec80ea0b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 2 Apr 2015 13:56:45 -0600 Subject: [PATCH 12/17] :arrow_up: text-buffer to fix marker restoration (fixes #6223) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b15919e9..371720500 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "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", "underscore-plus": "^1.6.6" From 89f082602b5b17c8b7a60a0573d8038358087f4b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 14:44:40 -0700 Subject: [PATCH 13/17] :arrow_up: grim@1.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 371720500..4b130c3a2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "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", From 14e75aacf921cd32d9b58263e4131ed8659d852a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 15:17:16 -0700 Subject: [PATCH 14/17] :arrow_up: archive-view@0.55 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b130c3a2..311d1c8f1 100644 --- a/package.json +++ b/package.json @@ -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", From 4c7fe0414b6f5784a83162c30fa76d7ff7418ece Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 15:18:19 -0700 Subject: [PATCH 15/17] :arrow_up: language-c@0.43 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 311d1c8f1..683d0badc 100644 --- a/package.json +++ b/package.json @@ -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", From aa4d294c19c4fcdcd30a95d94cdb525684d318d2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 17:19:20 -0700 Subject: [PATCH 16/17] Implement clearObservers in GrammarRegistry --- src/grammar-registry.coffee | 5 +++++ 1 file changed, 5 insertions(+) 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 From 2d5f848b4f49ebd507b3a8b18831aba682f0db7e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Apr 2015 17:29:03 -0700 Subject: [PATCH 17/17] :arrow_up: keybinding-resolver@0.30 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 683d0badc..795ee2bc6 100644 --- a/package.json +++ b/package.json @@ -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",