Pass autoIndent as an option flag

Instead of querying EditSession for autoIndenting
This commit is contained in:
Corey Johnson
2013-01-09 15:24:04 -08:00
parent 261a8aae2d
commit f5ee676e5e
4 changed files with 41 additions and 49 deletions

View File

@@ -92,7 +92,6 @@ class EditSession
getScrollLeft: -> @scrollLeft
setSoftWrapColumn: (@softWrapColumn) -> @displayBuffer.setSoftWrapColumn(@softWrapColumn)
setAutoIndent: (@autoIndent) ->
setSoftTabs: (@softTabs) ->
getSoftWrap: -> @softWrap
@@ -158,18 +157,23 @@ class EditSession
getCursorScopes: -> @getCursor().getScopes()
logScreenLines: (start, end) -> @displayBuffer.logLines(start, end)
insertText: (text, options) ->
shouldAutoIndent: ->
false
insertText: (text, options={}) ->
options.autoIndent ?= @shouldAutoIndent()
@mutateSelectedText (selection) -> selection.insertText(text, options)
insertNewline: ->
@insertText('\n', autoIndent: true)
@insertText('\n')
insertNewlineBelow: ->
@moveCursorToEndOfLine()
@insertNewline()
indent: ->
@mutateSelectedText (selection) -> selection.indent()
indent: (options={})->
options.autoIndent ?= @shouldAutoIndent()
@mutateSelectedText (selection) -> selection.indent(options)
backspace: ->
@mutateSelectedText (selection) -> selection.backspace()
@@ -216,9 +220,13 @@ class EditSession
selection.copy(maintainPasteboard)
maintainPasteboard = true
pasteText: ->
pasteText: (options={})->
options.normalizeIndent ?= true
[text, metadata] = pasteboard.read()
@insertText(text, _.extend(metadata ? {}, normalizeIndent: true))
_.extend(options, metadata) if metadata
@insertText(text, options)
undo: ->
@buffer.undo(this)