Snippets matching the cursor's word prefix are inserted on 'tab' events

This commit is contained in:
David Graham & Nathan Sobo
2012-06-19 17:47:09 -06:00
parent 4204b27751
commit 5b8cc8a6b6
6 changed files with 40 additions and 15 deletions

View File

@@ -32,6 +32,12 @@ class Buffer
getPath: ->
@path
getExtension: ->
if @getPath()
@getPath().split('/').pop().split('.').pop()
else
null
setPath: (path) ->
@path = path
@trigger "path-change", this

View File

@@ -155,6 +155,9 @@ class Cursor
getCurrentLineBufferRange: ->
@editSession.bufferRangeForBufferRow(@getBufferRow())
getCurrentWordPrefix: ->
@editSession.getTextInBufferRange([@getBeginningOfCurrentWordBufferPosition(), @getBufferPosition()])
isAtBeginningOfLine: ->
@getBufferPosition().column == 0

View File

@@ -329,6 +329,9 @@ class EditSession
getSelectedText: ->
@getLastSelection().getText()
getTextInBufferRange: (range) ->
@buffer.getTextInRange(range)
moveCursorUp: ->
@moveCursors (cursor) -> cursor.moveUp()

View File

@@ -23,8 +23,7 @@ class TokenizedBuffer
@aceAdaptor = new AceAdaptor(this)
requireAceMode: ->
extension = if @buffer.getPath() then @buffer.getPath().split('/').pop().split('.').pop() else null
modeName = switch extension
modeName = switch @buffer.getExtension()
when 'js' then 'javascript'
when 'coffee' then 'coffee'
when 'rb', 'ru' then 'ruby'