Only call replace on string arguments

Prevents errors being thrown when trying to call replace on non-string
arguments.
This commit is contained in:
Kevin Sawicki 2014-09-18 11:30:16 -07:00
parent 3fb22f123a
commit c37e4649b5
2 changed files with 6 additions and 2 deletions

View File

@ -71,7 +71,7 @@ describe "LanguageMode", ->
expect(languageMode.rowRangeForCodeFoldAtBufferRow(4)).toEqual [4, 7]
describe ".rowRangeForCommentAtBufferRow(bufferRow)", ->
it "returns the start/end rows of the foldable comment starting at the given row", ->
fit "returns the start/end rows of the foldable comment starting at the given row", ->
buffer.setText("//this is a multi line comment\n//another line")
expect(languageMode.rowRangeForCommentAtBufferRow(0)).toEqual [0, 1]
expect(languageMode.rowRangeForCommentAtBufferRow(1)).toEqual [0, 1]
@ -86,10 +86,12 @@ describe "LanguageMode", ->
expect(languageMode.rowRangeForCommentAtBufferRow(2)).toBeUndefined()
buffer.setText("//this is a single line comment\n")
console.log buffer.getLastRow()
expect(languageMode.rowRangeForCommentAtBufferRow(0)).toBeUndefined()
expect(languageMode.rowRangeForCommentAtBufferRow(1)).toBeUndefined()
buffer.setText("//this is a single line comment")
console.log languageMode.isLineCommentedAtBufferRow(0)
expect(languageMode.rowRangeForCommentAtBufferRow(0)).toBeUndefined()
describe "suggestedIndentForBufferRow", ->

View File

@ -49,8 +49,10 @@ class BufferedProcess
# Don't wrap /root,C:\folder style arguments to explorer calls in
# quotes since they will not be interpreted correctly if they are
arg
else
else if typeof arg is 'string'
"\"#{arg.replace(/"/g, '\\"')}\""
else
arg
else
cmdArgs = []
if /\s/.test(command)