Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @findDefinition = ->
- e = getActiveTextEditor()
- e.selectWordsContainingCursors()
- name = e.getSelectedText()
- found = false
- for test in [ "def +" + name + " ?\\(",
- "class +" + name + " ?\\(", "class +" + name + " ?:",
- name + " *=", "^[ \\t]*" + name + ",.+=",
- "import +" + name ]
- rexp = new RegExp(test)
- e.scan(rexp, (o)->
- if o.matchText.length > 0
- r = e.markBufferRange(o.range)
- e.selectMarker(r)
- o.stop()
- r.destroy()
- flash(e)
- found = true
- )
- if found
- return
- flashMarker: null
- flash = (editor) ->
- @flashMarker?.destroy()
- cursorPosition = editor.getCursorBufferPosition()
- @flashMarker = editor.markBufferPosition(cursorPosition)
- decorationOptions = {type: 'line', class: 'cursor-history-flash-line'}
- editor.decorateMarker(@flashMarker, decorationOptions)
- destroyMarker = =>
- disposable?.destroy()
- disposable = null
- @flashMarker?.destroy()
- disposable = editor.onDidChangeCursorPosition(destroyMarker)
- # [NOTE] animation-duration has to be shorter than this value(1sec)
- setTimeout(destroyMarker, 1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement