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:
Kevin Sawicki
2014-12-18 10:39:11 -08:00
parent 5115540f8e
commit c96f976162

View File

@@ -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