Skip to content

Commit c06d9d8

Browse files
committed
Improve English comments and messages
1 parent 434c4d4 commit c06d9d8

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

lib/error_highlight/base.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require_relative "version"
22

33
module ErrorHighlight
4-
# Identify the code fragment at that a given exception occurred.
4+
# Identify the code fragment where a given exception occurred.
55
#
66
# Options:
77
#
88
# point_type: :name | :args
9-
# :name (default) points the method/variable name that the exception occurred.
10-
# :args points the arguments of the method call that the exception occurred.
9+
# :name (default) points to the method/variable name where the exception occurred.
10+
# :args points to the arguments of the method call where the exception occurred.
1111
#
1212
# backtrace_location: Thread::Backtrace::Location
1313
# It locates the code fragment of the given backtrace_location.
@@ -113,7 +113,7 @@ def initialize(node, point_type: :name, name: nil)
113113
snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("")
114114
snippet += "\n" unless snippet.end_with?("\n")
115115

116-
# It require some work to support Unicode (or multibyte) characters.
116+
# It requires some work to support Unicode (or multibyte) characters.
117117
# Tentatively, we stop highlighting if the code snippet has non-ascii characters.
118118
# See https://github.com/ruby/error_highlight/issues/4
119119
raise NonAscii unless snippet.ascii_only?
@@ -504,7 +504,6 @@ def spot_fcall_for_name
504504
def spot_fcall_for_args
505505
_mid, nd_args = @node.children
506506
if nd_args && nd_args.first_lineno == nd_args.last_lineno
507-
# binary operator
508507
fetch_line(nd_args.first_lineno)
509508
@beg_column = nd_args.first_column
510509
@end_column = nd_args.last_column

lib/error_highlight/core_ext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module CoreExt
2424
_, _, snippet, highlight = ErrorHighlight.formatter.message_for(spot).lines
2525
out += "\n | #{ snippet } #{ highlight }"
2626
else
27-
out += "\n (cannot create a snippet of the method definition; use Ruby 3.5 or later)"
27+
out += "\n (cannot highlight method definition; try Ruby 3.5 or later)"
2828
end
2929
end
3030
ret << "\n" + out if out

lib/error_highlight/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def self.max_snippet_width=(width)
5656
end
5757

5858
def self.terminal_width
59-
# lazy load io/console, so it's not loaded when 'max_snippet_width' is set
59+
# lazy load io/console to avoid loading it when 'max_snippet_width' is manually set
6060
require "io/console"
6161
$stderr.winsize[1] if $stderr.tty?
6262
rescue LoadError, NoMethodError, SystemCallError
63-
# do not truncate when window size is not available
63+
# skip truncation when terminal window size is unavailable
6464
end
6565
end
6666

0 commit comments

Comments
 (0)