If selection is empty when toggling a line comment, keep it empty

This commit is contained in:
Nathan Sobo
2012-06-04 11:50:48 -06:00
parent 14e399fdf0
commit b667ba4262
3 changed files with 8 additions and 1 deletions

View File

@@ -292,6 +292,13 @@ describe "Selection", ->
expect(buffer.lineForRow(6)).toBe " current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe " }"
it "preserves selection emptiness", ->
editor.attachToDom()
selection.setBufferRange([[4, 0], [4, 0]])
selection.toggleLineComments()
expect(selection.isEmpty()).toBeTruthy()
expect(selection.find('.selection')).not.toExist()
describe "when the selection ends on the begining of a fold line", ->
beforeEach ->
editor.createFold(2,4)

View File

@@ -248,7 +248,6 @@ class Renderer
@lineMap.logLines(start, end)
toggleLineCommentsInRange: (range) ->
console.log range.inspect()
@lineCommenter.toggleLineCommentsInRange(range)
_.extend Renderer.prototype, EventEmitter

View File

@@ -20,6 +20,7 @@ class Selection extends View
handleBufferChange: (e) ->
return unless @anchor
@anchor.handleBufferChange(e)
@updateAppearance()
placeAnchor: ->
return if @anchor