Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Make textmate formtatter run prettier #419

Merged
merged 1 commit into from
Jul 1, 2011
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/rspec/core/formatters/snippet_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class NullConverter; def convert(code, pre); code; end; end #:nodoc:

def snippet(error)
raw_code, line = snippet_for(error.backtrace[0])

# skip over whiny_nils in the backtrace
raw_code, line = snippet_for(error.backtrace[1]) if error.backtrace[0] =~ /active_support\/whiny_nil\.rb/

highlighted = @@converter.convert(raw_code, false)
highlighted << "\n<span class=\"comment\"># gem install syntax to get syntax highlighting</span>" if @@converter.is_a?(NullConverter)
post_process(highlighted, line)
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/core/formatters/text_mate_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'cgi'
require 'rspec/core/formatters/html_formatter'

module RSpec
Expand All @@ -7,6 +8,7 @@ module Formatters
class TextMateFormatter < HtmlFormatter
def backtrace_line(line)
if line = super(line)
line = CGI.escapeHTML(line)
line.sub!(/([^:]*\.e?rb):(\d*)/) do
"<a href=\"txmt://open?url=file://#{File.expand_path($1)}&line=#{$2}\">#{$1}:#{$2}</a> "
end
Expand Down