mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Don't explode on meta-/ if there isn't a valid comment regex
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Project = require 'project'
|
||||
Buffer = require 'buffer'
|
||||
EditSession = require 'edit-session'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
|
||||
describe "EditSession", ->
|
||||
[buffer, editSession, lineLengths] = []
|
||||
@@ -1347,6 +1348,12 @@ describe "EditSession", ->
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(editSession.getSelection().isEmpty()).toBeTruthy()
|
||||
|
||||
it "does not explode if the current language mode has no comment regex", ->
|
||||
spyOn(TextMateBundle, 'lineCommentStringForScope').andReturn(null)
|
||||
editSession.setSelectedBufferRange([[4, 5], [4, 5]])
|
||||
editSession.toggleLineCommentsInSelection()
|
||||
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
|
||||
|
||||
describe ".undo() and .redo()", ->
|
||||
it "undoes/redoes the last change", ->
|
||||
editSession.insertText("foo")
|
||||
|
||||
@@ -47,7 +47,8 @@ class LanguageMode
|
||||
toggleLineCommentsInRange: (range) ->
|
||||
range = Range.fromObject(range)
|
||||
scopes = @tokenizedBuffer.scopesForPosition(range.start)
|
||||
commentString = TextMateBundle.lineCommentStringForScope(scopes[0])
|
||||
return unless commentString = TextMateBundle.lineCommentStringForScope(scopes[0])
|
||||
|
||||
commentRegex = new OnigRegExp("^\s*" + _.escapeRegExp(commentString))
|
||||
|
||||
shouldUncomment = commentRegex.test(@editSession.lineForBufferRow(range.start.row))
|
||||
|
||||
Reference in New Issue
Block a user