From c37e4649b55495bbbcc4e12cbc19f7cc557ad5b6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 11:30:16 -0700 Subject: [PATCH] Only call replace on string arguments Prevents errors being thrown when trying to call replace on non-string arguments. --- spec/language-mode-spec.coffee | 4 +++- src/buffered-process.coffee | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/language-mode-spec.coffee b/spec/language-mode-spec.coffee index f6f0ebdd7..0c0fba9b0 100644 --- a/spec/language-mode-spec.coffee +++ b/spec/language-mode-spec.coffee @@ -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", -> diff --git a/src/buffered-process.coffee b/src/buffered-process.coffee index 0a7751e57..9bb8cc4ae 100644 --- a/src/buffered-process.coffee +++ b/src/buffered-process.coffee @@ -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)