Skip to content

Commit f86d343

Browse files
committed
fix NoMethodError
NoMethodError - undefined method `gsub' for nil:NilClass: barkeep/lib/syntax_highlighter.rb:51:in `global_highlighting' barkeep/lib/syntax_highlighter.rb:25:in `colorize_blob' barkeep/lib/git_diff_utils.rb:48:in `block in get_tagged_commit_diffs' barkeep/lib/git_diff_utils.rb:26:in `map' barkeep/lib/git_diff_utils.rb:26:in `get_tagged_commit_diffs' barkeep/barkeep_server.rb:327:in `block in <class:BarkeepServer>'
1 parent a53f9c7 commit f86d343

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎lib/syntax_highlighter.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def self.pygmentize(file_type, text)
4848
# NOTE(caleb): It might be possible/better to do this in Python. However, that will probably involve
4949
# modifying Pygments (monkey-patching isn't so simple in Python) and in general will be more work.
5050
def self.global_highlighting(pygmentized_text)
51-
pygmentized_text.gsub(/[ \t]+$/) { |whitespace| "<span class='trailingWhitespace'>#{whitespace}</span>" }
51+
unless pygmentized_text.nil?
52+
pygmentized_text.gsub(/[ \t]+$/) { |whitespace| "<span class='trailingWhitespace'>#{whitespace}</span>" }
53+
end
5254
end
5355

5456
def self.redis_cache_key(repo_name, blob)

0 commit comments

Comments
 (0)