From 3cbc39be02c4a8bac7548e1599b1f80442f16cfb Mon Sep 17 00:00:00 2001 From: Brian Tsai Date: Fri, 29 Mar 2013 07:50:51 +0900 Subject: [PATCH 1/2] Update comment.rb It looks like source.ruble/lib/comment.rb is missing some code. Change line 218 from: index = l.index(/\S/) to: index = @disable_indent ? 0 : l.index(/\S/) Then in your language bundle (like ruby.ruble/bundle.rb or js.ruble/bundle.rb), in the block: env 'source.ruby' do |e| add: e['TM_COMMENT_DISABLE_INDENT'] = 'YES' Personally, to avoid any problems with the wrong value being passed in for TM_COMMENT_DISABLE_INDENT, I would also change line 8 of source.ruble/lib/comment.rb from: @disable_indent = (disable_indent == 'YES') to: @disable_indent = (disable_indent.downcase == 'yes') --- lib/comment.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/comment.rb b/lib/comment.rb index b1174ef..122bbf4 100644 --- a/lib/comment.rb +++ b/lib/comment.rb @@ -5,7 +5,7 @@ class Comment def initialize(context, start_chars, end_chars, disable_indent) @context, @start_chars, @end_chars = context, start_chars, end_chars - @disable_indent = (disable_indent == 'YES') + @disable_indent = (disable_indent.downcase == 'yes') end def Comment.from_env(context) @@ -213,10 +213,10 @@ def add(lines) if lines.empty? output = @start_chars else - # Prepend the comment beginning to each line, Retain existing indent (that's the index/regexp thing)! + # Prepend the comment beginning to each line, Retain existing indent if required (that's the index/regexp thing)! lines.each do |l| next unless l - index = l.index(/\S/) + index = @disable_indent ? 0 : l.index(/\S/) if index output << "#{l[0...index]}#{@start_chars}#{l[index..-1]}#{newline}" else @@ -276,4 +276,4 @@ def expanded_lines(lines) def mode :line end -end \ No newline at end of file +end From 90b277614cc639cec7e32c7f1dd07b39a55f7cd6 Mon Sep 17 00:00:00 2001 From: Brian Tsai Date: Fri, 29 Mar 2013 13:20:51 +0900 Subject: [PATCH 2/2] Update comment.rb --- lib/comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/comment.rb b/lib/comment.rb index 122bbf4..3e55bbd 100644 --- a/lib/comment.rb +++ b/lib/comment.rb @@ -5,7 +5,7 @@ class Comment def initialize(context, start_chars, end_chars, disable_indent) @context, @start_chars, @end_chars = context, start_chars, end_chars - @disable_indent = (disable_indent.downcase == 'yes') + @disable_indent = (disable_indent && disable_indent.downcase == 'yes') end def Comment.from_env(context)