Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @findDefinition = ->
  2.     e = getActiveTextEditor()
  3.     e.selectWordsContainingCursors()
  4.     name = e.getSelectedText()
  5.     found = false
  6.     for test in [ "def +" + name, name + " *=", name + ",.+=" ]
  7.         rexp = new RegExp(test)
  8.         e.scan(rexp, (o)->
  9.             if o.matchText.length > 0
  10.                 r = e.markBufferRange(o.range)
  11.                 e.selectMarker(r)
  12.                 o.stop()
  13.                 r.destroy()
  14.                 flash(e)
  15.                 found = true
  16.         )
  17.         if found
  18.             return
  19.  
  20.  
  21. flashMarker: null
  22. flash = (editor) ->
  23.     @flashMarker?.destroy()
  24.     cursorPosition = editor.getCursorBufferPosition()
  25.     @flashMarker = editor.markBufferPosition(cursorPosition)
  26.     decorationOptions = {type: 'line', class: 'cursor-history-flash-line'}
  27.     editor.decorateMarker(@flashMarker, decorationOptions)
  28.  
  29.     destroyMarker = =>
  30.         disposable?.destroy()
  31.         disposable = null
  32.         @flashMarker?.destroy()
  33.  
  34.     disposable = editor.onDidChangeCursorPosition(destroyMarker)
  35.     # [NOTE] animation-duration has to be shorter than this value(1sec)
  36.     setTimeout(destroyMarker, 1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement