mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Write to selection clipboard from setTimeout
This is so that in progress transactions aren't written to the selection clipboard.
This commit is contained in:
@@ -435,12 +435,16 @@ TextEditorComponent = React.createClass
|
||||
# Listen for selection changes and store the currently selected text
|
||||
# in the selection clipboard. This is only applicable on Linux.
|
||||
trackSelectionClipboard: ->
|
||||
@subscribe @props.editor.onDidChangeSelectionRange =>
|
||||
timeoutId = null
|
||||
writeSelectedTextToSelectionClipboard = =>
|
||||
if selectedText = @props.editor.getSelectedText()
|
||||
# This uses ipc.send instead of clipboard.writeText because
|
||||
# clipboard.writeText is a sync ipc call on Linux and that
|
||||
# will slow down selections.
|
||||
ipc.send('write-text-to-selection-clipboard', selectedText)
|
||||
@subscribe @props.editor.onDidChangeSelectionRange =>
|
||||
clearTimeout(timeoutId)
|
||||
timeoutId = setTimeout(writeSelectedTextToSelectionClipboard)
|
||||
|
||||
observeConfig: ->
|
||||
@subscribe atom.config.observe 'editor.useHardwareAcceleration', @setUseHardwareAcceleration
|
||||
|
||||
Reference in New Issue
Block a user