mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Auto-outdent maintains proper cursor positon.
This commit is contained in:
parent
fe07e45ebc
commit
0737529f07
@ -463,6 +463,8 @@ describe "Editor", ->
|
||||
editor.insertText("}")
|
||||
expect(editor.buffer.getLine(2)).toEqual(" }")
|
||||
|
||||
expect(editor.getCursorBufferPosition().column).toBe 3
|
||||
|
||||
describe "selection", ->
|
||||
selection = null
|
||||
|
||||
|
@ -2,7 +2,7 @@ Range = require 'range'
|
||||
|
||||
module.exports =
|
||||
class AceOutdentAdaptor
|
||||
constructor: (@buffer) ->
|
||||
constructor: (@buffer, @editor) ->
|
||||
|
||||
getLine: (row) ->
|
||||
@buffer.getLine(row)
|
||||
@ -13,6 +13,9 @@ class AceOutdentAdaptor
|
||||
|
||||
# Does not actually replace text, just line at range.start outdents one level
|
||||
replace: (range, text) ->
|
||||
{row, column} = @editor.getCursorBufferPosition()
|
||||
start = range.start
|
||||
end = {row: range.start.row, column: range.start.column + atom.tabText.length}
|
||||
@buffer.change(new Range(start, end), "")
|
||||
@editor.setCursorBufferPosition({row, column: column - atom.tabText.length})
|
||||
|
||||
|
@ -324,7 +324,7 @@ class Editor extends View
|
||||
|
||||
autoOutdentText: ->
|
||||
state = @lineWrapper.lineForScreenRow(@getCursorRow()).state
|
||||
@buffer.mode.autoOutdent(state, new AceOutdentAdaptor(@buffer), @getCursorRow())
|
||||
@buffer.mode.autoOutdent(state, new AceOutdentAdaptor(@buffer, this), @getCursorRow())
|
||||
|
||||
cutSelection: -> @selection.cut()
|
||||
copySelection: -> @selection.copy()
|
||||
|
Loading…
Reference in New Issue
Block a user