mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Inserting a newline indents the cursor (based on information from previous line)
This commit is contained in:
parent
3ff8a1e92c
commit
53fc625534
@ -440,6 +440,14 @@ describe "Editor", ->
|
||||
editor.lines.trigger 'mouseup'
|
||||
expect(editor.getSelectedText()).toBe " if (items.length <= 1) return items;"
|
||||
|
||||
describe "auto indent/outdent", ->
|
||||
describe "when newline is inserted", ->
|
||||
it "indents cursor based on the indentation of previous line", ->
|
||||
editor.setCursorBufferPosition([4, 29])
|
||||
editor.insertText("\n")
|
||||
|
||||
expect(editor.buffer.getLine(5)).toEqual(" ")
|
||||
|
||||
describe "selection", ->
|
||||
selection = null
|
||||
|
||||
@ -829,5 +837,3 @@ describe "Editor", ->
|
||||
expect(editor.lines.find('.line:eq(5)').text()).toBe ' current = items.shift();'
|
||||
|
||||
expect(editor.getCursorBufferPosition()).toEqual [4, 29]
|
||||
|
||||
|
||||
|
@ -300,7 +300,14 @@ class Editor extends View
|
||||
selectToBufferPosition: (position) ->
|
||||
@selection.selectToBufferPosition(position)
|
||||
|
||||
insertText: (text) -> @selection.insertText(text)
|
||||
insertText: (text) ->
|
||||
if text[0] == "\n"
|
||||
tab = " "
|
||||
state = @lineWrapper.lineForScreenRow(@getRow).state
|
||||
indent = @buffer.mode.getNextLineIndent(state, @getCurrentLine(), tab)
|
||||
text = text[0] + indent + text[1..]
|
||||
|
||||
@selection.insertText(text)
|
||||
|
||||
cutSelection: -> @selection.cut()
|
||||
copySelection: -> @selection.copy()
|
||||
|
Loading…
Reference in New Issue
Block a user