Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comment.rb #5

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/comment.rb
Original file line number Diff line number Diff line change
@@ -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 && 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
end