From e7b4ad48f087a0006aa04d1604eb20ec543bc3bb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 3 Jul 2017 16:10:41 -0600 Subject: [PATCH 01/12] Always render 'decoration' class on custom decorations --- spec/text-editor-component-spec.js | 10 +++++----- src/text-editor-component.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 7c211ef29..e36da68c1 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -1727,17 +1727,17 @@ describe('TextEditorComponent', () => { let [decorationNode1, decorationNode2] = gutterA.getElement().firstChild.children const [decorationNode3] = gutterB.getElement().firstChild.children - expect(decorationNode1.className).toBe('a') + expect(decorationNode1.className).toBe('decoration a') expect(decorationNode1.getBoundingClientRect().top).toBe(clientTopForLine(component, 2)) expect(decorationNode1.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 5)) expect(decorationNode1.firstChild).toBeNull() - expect(decorationNode2.className).toBe('b') + expect(decorationNode2.className).toBe('decoration b') expect(decorationNode2.getBoundingClientRect().top).toBe(clientTopForLine(component, 6)) expect(decorationNode2.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 8)) expect(decorationNode2.firstChild).toBe(decorationElement1) - expect(decorationNode3.className).toBe('') + expect(decorationNode3.className).toBe('decoration') expect(decorationNode3.getBoundingClientRect().top).toBe(clientTopForLine(component, 9)) expect(decorationNode3.getBoundingClientRect().bottom).toBe(clientTopForLine(component, 12) + component.getLineHeight()) expect(decorationNode3.firstChild).toBe(decorationElement2) @@ -1746,9 +1746,9 @@ describe('TextEditorComponent', () => { decoration2.setProperties({type: 'gutter', gutterName: 'a', item: decorationElement2}) decoration3.destroy() await component.getNextUpdatePromise() - expect(decorationNode1.className).toBe('c') + expect(decorationNode1.className).toBe('decoration c') expect(decorationNode1.firstChild).toBe(decorationElement1) - expect(decorationNode2.className).toBe('') + expect(decorationNode2.className).toBe('decoration') expect(decorationNode2.firstChild).toBe(decorationElement2) expect(gutterB.getElement().firstChild.children.length).toBe(0) }) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 4e52c5d08..5f4c28415 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1105,7 +1105,7 @@ class TextEditorComponent { const height = this.pixelPositionBeforeBlocksForRow(screenRange.end.row + 1) - top decorations.push({ - className: decoration.class, + className: 'decoration' + (decoration.class ? ' ' + decoration.class : ''), element: TextEditor.viewForItem(decoration.item), top, height From e3704932a439708f8ab3420238ae48af939fe74c Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Thu, 6 Jul 2017 15:50:17 -0400 Subject: [PATCH 02/12] :arrow_up: spell-check --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9081c2266..27492ad16 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "package-generator": "1.1.1", "settings-view": "0.250.0", "snippets": "1.1.4", - "spell-check": "0.71.4", + "spell-check": "0.72.0", "status-bar": "1.8.11", "styleguide": "0.49.6", "symbols-view": "0.116.1", From 1e118a247310f135e597f12586211e4a773df4a5 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Thu, 6 Jul 2017 19:46:21 -0400 Subject: [PATCH 03/12] :arrow_up: settings-view --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27492ad16..01519af64 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "notifications": "0.67.2", "open-on-github": "1.2.1", "package-generator": "1.1.1", - "settings-view": "0.250.0", + "settings-view": "0.251.0", "snippets": "1.1.4", "spell-check": "0.72.0", "status-bar": "1.8.11", From 0219a1de0f49a1c6b8010c87f9bb169225902f46 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Thu, 6 Jul 2017 22:38:46 -0700 Subject: [PATCH 04/12] :arrow_up: metrics --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01519af64..1b25dddf8 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "line-ending-selector": "0.7.3", "link": "0.31.3", "markdown-preview": "0.159.13", - "metrics": "1.2.5", + "metrics": "1.2.6", "notifications": "0.67.2", "open-on-github": "1.2.1", "package-generator": "1.1.1", From e392154dad6caf824b4417242202af7e5791245a Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 7 Jul 2017 09:29:19 +0200 Subject: [PATCH 05/12] :arrow_up: text-buffer 13.0.6-0 Signed-off-by: Nathan Sobo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b25dddf8..71bbc38c5 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "sinon": "1.17.4", "@atom/source-map-support": "^0.3.4", "temp": "^0.8.3", - "text-buffer": "13.0.5", + "text-buffer": "13.0.6-0", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", "winreg": "^1.2.1", From e5fd511e235bec67878e4799438f4fae63569c0f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 7 Jul 2017 10:09:09 +0200 Subject: [PATCH 06/12] :arrow_up: text-buffer 13.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 71bbc38c5..c021aebd9 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "sinon": "1.17.4", "@atom/source-map-support": "^0.3.4", "temp": "^0.8.3", - "text-buffer": "13.0.6-0", + "text-buffer": "13.0.6", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", "winreg": "^1.2.1", From d09536915537f5843402c94f1254efbfc94900f5 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 10 Jul 2017 01:12:49 -0400 Subject: [PATCH 07/12] :arrow_up: settings-view@0.251.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c021aebd9..596641b46 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "notifications": "0.67.2", "open-on-github": "1.2.1", "package-generator": "1.1.1", - "settings-view": "0.251.0", + "settings-view": "0.251.1", "snippets": "1.1.4", "spell-check": "0.72.0", "status-bar": "1.8.11", From 3c3a0e350366197fadaa80f742a78788fb9f2ec1 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Mon, 10 Jul 2017 12:50:44 -0400 Subject: [PATCH 08/12] :arrow_up: atom-keymap --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 596641b46..c1ff8925d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "electronVersion": "1.6.9", "dependencies": { "async": "0.2.6", - "atom-keymap": "8.2.1", + "atom-keymap": "8.2.2", "atom-select-list": "^0.1.0", "atom-ui": "0.4.1", "babel-core": "5.8.38", From 82619a989b8235f3044ea416bc17137704228b93 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 10 Jul 2017 14:27:55 -0600 Subject: [PATCH 09/12] :art: --- src/text-editor-component.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index b44fac331..fef64d654 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1645,10 +1645,11 @@ class TextEditorComponent { didMouseDownOnContent (event) { const {model} = this.props const {target, button, detail, ctrlKey, shiftKey, metaKey} = event + const platform = this.getPlatform() // Only handle mousedown events for left mouse button (or the middle mouse // button on Linux where it pastes the selection clipboard). - if (!(button === 0 || (this.getPlatform() === 'linux' && button === 1))) return + if (!(button === 0 || (platform === 'linux' && button === 1))) return const screenPosition = this.screenPositionForMouseEvent(event) @@ -1659,14 +1660,14 @@ class TextEditorComponent { } // Handle middle mouse button only on Linux (paste clipboard) - if (this.getPlatform() === 'linux' && button === 1) { + if (platform === 'linux' && button === 1) { const selection = clipboard.readText('selection') model.setCursorScreenPosition(screenPosition, {autoscroll: false}) model.insertText(selection) return } - const addOrRemoveSelection = metaKey || (ctrlKey && this.getPlatform() !== 'darwin') + const addOrRemoveSelection = metaKey || (ctrlKey && platform !== 'darwin') switch (detail) { case 1: From cd27b49dc471db63c82850d119e7c98293f251a2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 10 Jul 2017 14:28:21 -0600 Subject: [PATCH 10/12] Don't handle ctrl-click events on macOS It brings up the context menu, so we shouldn't change the cursor position --- src/text-editor-component.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index fef64d654..dfcdbc150 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1667,6 +1667,9 @@ class TextEditorComponent { return } + // Ctrl-click brings up the context menu on macOS + if (platform === 'darwin' && ctrlKey) return + const addOrRemoveSelection = metaKey || (ctrlKey && platform !== 'darwin') switch (detail) { From f6d2f966bfb57492632c65c23e318dd792bbdced Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 10 Jul 2017 15:53:23 -0600 Subject: [PATCH 11/12] Fix middle-mouse-button paste on Linux Chrome now synthesizes a textInput event on mouseup for middle mouse button clicks, which rendered our custom JS for handling that case redundant. --- spec/text-editor-component-spec.js | 37 +++++++----------------------- src/text-editor-component.js | 25 ++++++++++---------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 555ee3015..2028ae8bd 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -2412,10 +2412,13 @@ describe('TextEditorComponent', () => { ctrlKey: true }) ) - expect(editor.getCursorScreenPositions()).toEqual([[1, 4]]) + expect(editor.getSelectedScreenRanges()).toEqual([ + [[1, 16], [1, 16]] + ]) // ctrl-click adds cursors on platforms *other* than macOS component.props.platform = 'win32' + editor.setCursorScreenPosition([1, 4]) component.didMouseDownOnContent( Object.assign(clientPositionForCharacter(component, 1, 16), { detail: 1, @@ -2675,42 +2678,18 @@ describe('TextEditorComponent', () => { expect(component.getScrollLeft()).toBe(maxScrollLeft) }) - it('pastes the previously selected text when clicking the middle mouse button on Linux', async () => { - spyOn(electron.ipcRenderer, 'send').andCallFake(function (eventName, selectedText) { - if (eventName === 'write-text-to-selection-clipboard') { - clipboard.writeText(selectedText, 'selection') - } - }) - + it('positions the cursor on clicking the middle mouse button on Linux', async () => { + // The browser synthesizes the paste as a textInput event on mouseup + // so it is not possible to test it here. const {component, editor} = buildComponent({platform: 'linux'}) - // Middle mouse pasting. editor.setSelectedBufferRange([[1, 6], [1, 10]]) - await conditionPromise(() => TextEditor.clipboard.read() === 'sort') component.didMouseDownOnContent({ button: 1, clientX: clientLeftForCharacter(component, 10, 0), clientY: clientTopForLine(component, 10) }) - expect(TextEditor.clipboard.read()).toBe('sort') - expect(editor.lineTextForBufferRow(10)).toBe('sort') - editor.undo() - - // Ensure left clicks don't interfere. - editor.setSelectedBufferRange([[1, 2], [1, 5]]) - await conditionPromise(() => TextEditor.clipboard.read() === 'var') - component.didMouseDownOnContent({ - button: 0, - detail: 1, - clientX: clientLeftForCharacter(component, 10, 0), - clientY: clientTopForLine(component, 10) - }) - component.didMouseDownOnContent({ - button: 1, - clientX: clientLeftForCharacter(component, 10, 0), - clientY: clientTopForLine(component, 10) - }) - expect(editor.lineTextForBufferRow(10)).toBe('var') + expect(editor.getSelectedBufferRange()).toEqual([[10, 0], [10, 0]]) }) }) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index dfcdbc150..cf9e5c53f 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1647,9 +1647,21 @@ class TextEditorComponent { const {target, button, detail, ctrlKey, shiftKey, metaKey} = event const platform = this.getPlatform() + // On Linux, position the cursor on middle mouse button click. A + // textInput event with the contents of the selection clipboard will be + // dispatched by the browser automatically on mouseup. + if (platform === 'linux' && button === 1) { + const screenPosition = this.screenPositionForMouseEvent(event) + model.setCursorScreenPosition(screenPosition, {autoscroll: false}) + return + } + // Only handle mousedown events for left mouse button (or the middle mouse // button on Linux where it pastes the selection clipboard). - if (!(button === 0 || (platform === 'linux' && button === 1))) return + if (button !== 0) return + + // Ctrl-click brings up the context menu on macOS + if (platform === 'darwin' && ctrlKey) return const screenPosition = this.screenPositionForMouseEvent(event) @@ -1659,17 +1671,6 @@ class TextEditorComponent { return } - // Handle middle mouse button only on Linux (paste clipboard) - if (platform === 'linux' && button === 1) { - const selection = clipboard.readText('selection') - model.setCursorScreenPosition(screenPosition, {autoscroll: false}) - model.insertText(selection) - return - } - - // Ctrl-click brings up the context menu on macOS - if (platform === 'darwin' && ctrlKey) return - const addOrRemoveSelection = metaKey || (ctrlKey && platform !== 'darwin') switch (detail) { From 07c7e53b1eb620064e9d81004438f3028d22151a Mon Sep 17 00:00:00 2001 From: ungb Date: Mon, 10 Jul 2017 16:26:47 -0700 Subject: [PATCH 12/12] fix lint errors --- src/text-editor-component.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index cf9e5c53f..037e45462 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -5,7 +5,6 @@ const {Point, Range} = require('text-buffer') const LineTopIndex = require('line-top-index') const TextEditor = require('./text-editor') const {isPairedCharacter} = require('./text-utils') -const clipboard = require('./safe-clipboard') const electron = require('electron') const $ = etch.dom