mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Always place cursor at end of selection after inserting text
This commit is contained in:
parent
84ba78c55d
commit
158315ffaa
@ -1457,10 +1457,16 @@ describe "Editor", ->
|
||||
|
||||
describe "when there is a selection", ->
|
||||
it "replaces the selected text with the typed text", ->
|
||||
editor.getSelection().setBufferRange(new Range([1, 6], [2, 4]))
|
||||
editor.setSelectionBufferRange(new Range([1, 6], [2, 4]))
|
||||
editor.hiddenInput.textInput 'q'
|
||||
expect(buffer.lineForRow(1)).toBe ' var qif (items.length <= 1) return items;'
|
||||
|
||||
it "always places the cursor after the selection", ->
|
||||
editor.setSelectionBufferRange(new Range([1, 6], [2, 4]), reverse: true)
|
||||
editor.hiddenInput.textInput 'q'
|
||||
expect(buffer.lineForRow(1)).toBe ' var qif (items.length <= 1) return items;'
|
||||
expect(editor.getCursorScreenPosition()).toEqual [1, 7]
|
||||
|
||||
describe "when return is pressed", ->
|
||||
describe "when the cursor is at the beginning of a line", ->
|
||||
it "inserts an empty line before it", ->
|
||||
|
@ -102,6 +102,7 @@ class Selection extends View
|
||||
{ text, shouldOutdent } = @autoIndentText(text)
|
||||
@editor.buffer.change(@getBufferRange(), text)
|
||||
@autoOutdentText() if shouldOutdent
|
||||
@cursor.setScreenPosition(@getScreenRange().end)
|
||||
@clearSelection()
|
||||
|
||||
autoIndentText: (text) ->
|
||||
|
Loading…
Reference in New Issue
Block a user