Skip to content

Instantly share code, notes, and snippets.

@t9md
Created May 16, 2017 16:40
Show Gist options
  • Save t9md/57563bd0e8eff94f61d99569adc099c9 to your computer and use it in GitHub Desktop.
Save t9md/57563bd0e8eff94f61d99569adc099c9 to your computer and use it in GitHub Desktop.
atom-narrow start-search-by-double-click
startNarrow = (element, event) ->
{detail, shiftKey, metaKey, ctrlKey} = event
# console.log [shiftKey, metaKey, ctrlKey]
if detail is 2
# if detail is 2 # double-click
event.stopPropagation()
event.preventDefault()
if atom.workspace.getElement().classList.contains('has-narrow')
command = 'narrow:query-current-word'
else
command = 'narrow:search-by-current-word-without-focus'
atom.commands.dispatch(element, command)
atom.workspace.observeTextEditors ({element}) ->
onMouseDown = startNarrow.bind(null, element)
element.addEventListener('mousedown', onMouseDown, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment