Skip to content

Commit c907709

Browse files
Support for BETTER_ERRORS_EDITOR_URL
1 parent 4f95f3b commit c907709

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/better_errors/editor.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def self.for_symbol(symbol)
6161
#
6262
# @return [Symbol]
6363
def self.default_editor
64+
editor_from_environment_formatting_string ||
65+
editor_from_environment_editor ||
66+
for_symbol(:textmate)
67+
end
68+
69+
def self.editor_from_environment_editor
6470
editor_command = ENV["EDITOR"] || ENV["BETTER_ERRORS_EDITOR"]
6571
if editor_command
6672
editor = editor_from_command(editor_command)
@@ -70,12 +76,17 @@ def self.default_editor
7076
else
7177
puts "Since there is no EDITOR or BETTER_ERRORS_EDITOR environment variable, using Textmate by default."
7278
end
73-
for_symbol(:textmate)
7479
end
7580

7681
def self.editor_from_command(editor_command)
7782
env_preset = KNOWN_EDITORS.find { |preset| editor_command =~ preset[:sniff] }
7883
for_formatting_string(env_preset[:url]) if env_preset
7984
end
85+
86+
def self.editor_from_environment_formatting_string
87+
return unless ENV['BETTER_ERRORS_EDITOR_URL']
88+
89+
for_formatting_string(ENV['BETTER_ERRORS_EDITOR_URL'])
90+
end
8091
end
8192
end

0 commit comments

Comments
 (0)