mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Support outdenting when indent is < 1 tab length
This commit is contained in:
parent
518d88a4ab
commit
ab8c22825c
@ -1291,6 +1291,27 @@ describe "EditSession", ->
|
||||
expect(buffer.lineForRow(1)).toBe "var sort = function(items) {"
|
||||
expect(editSession.getSelectedBufferRange()).toEqual [[1, 3 - editSession.tabLength], [1, 3 - editSession.tabLength]]
|
||||
|
||||
it "outdents when indent is less than a tab length", ->
|
||||
editSession.insertText(' ')
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
|
||||
|
||||
it "outdents a single hard tab when indent is multiple hard tabs and and the session is using soft tabs", ->
|
||||
editSession.insertText('\t\t')
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe "\tvar quicksort = function () {"
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
|
||||
|
||||
it "outdents when a mix of hard tabs and soft tabs are used", ->
|
||||
editSession.insertText('\t ')
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe " var quicksort = function () {"
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe " var quicksort = function () {"
|
||||
editSession.outdentSelectedRows()
|
||||
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
|
||||
|
||||
describe "when one line is selected", ->
|
||||
it "outdents line and retains editSession", ->
|
||||
editSession.setSelectedBufferRange([[1,4], [1,14]])
|
||||
|
@ -108,6 +108,7 @@ class EditSession
|
||||
setSoftWrap: (@softWrap) ->
|
||||
|
||||
getTabText: -> new Array(@tabLength + 1).join(" ")
|
||||
getTabLength: -> @tabLength
|
||||
|
||||
clipBufferPosition: (bufferPosition) ->
|
||||
@buffer.clipPosition(bufferPosition)
|
||||
|
@ -213,10 +213,10 @@ class Selection
|
||||
outdentSelectedRows: ->
|
||||
range = @getBufferRange()
|
||||
buffer = @editSession.buffer
|
||||
leadingTabRegex = new RegExp("^#{@editSession.getTabText()}")
|
||||
leadingTabRegex = new RegExp("^ {1,#{@editSession.getTabLength()}}|\t")
|
||||
for row in [range.start.row..range.end.row]
|
||||
if leadingTabRegex.test buffer.lineForRow(row)
|
||||
buffer.delete [[row, 0], [row, @editSession.tabLength]]
|
||||
if matchLength = buffer.lineForRow(row).match(leadingTabRegex)?[0].length
|
||||
buffer.delete [[row, 0], [row, matchLength]]
|
||||
|
||||
toggleLineComments: ->
|
||||
@modifySelection =>
|
||||
|
Loading…
Reference in New Issue
Block a user