mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Merge remote-tracking branch 'origin/master' into mkt-updoot-github-0.3.5
This commit is contained in:
10
package.json
10
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",
|
||||
@@ -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",
|
||||
"typescript-simple": "1.0.0",
|
||||
"underscore-plus": "^1.6.6",
|
||||
"winreg": "^1.2.1",
|
||||
@@ -114,13 +114,13 @@
|
||||
"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",
|
||||
"settings-view": "0.250.0",
|
||||
"settings-view": "0.251.1",
|
||||
"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",
|
||||
|
||||
@@ -1746,17 +1746,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)
|
||||
@@ -1765,9 +1765,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)
|
||||
})
|
||||
@@ -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]])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1117,7 +1116,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
|
||||
@@ -1645,10 +1644,23 @@ class TextEditorComponent {
|
||||
didMouseDownOnContent (event) {
|
||||
const {model} = this.props
|
||||
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 || (this.getPlatform() === '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)
|
||||
|
||||
@@ -1658,15 +1670,7 @@ class TextEditorComponent {
|
||||
return
|
||||
}
|
||||
|
||||
// Handle middle mouse button only on Linux (paste clipboard)
|
||||
if (this.getPlatform() === '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:
|
||||
|
||||
Reference in New Issue
Block a user