aboutsummaryrefslogtreecommitdiffstats
path: root/lib/error_highlight
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-07-13 16:53:52 +0900
committergit <svn-admin@ruby-lang.org>2021-07-13 16:54:17 +0900
commit5fd5d71a4b100fdeca55352a5441b095a1d82e16 (patch)
treebfb995c4bf921eb6ff5cfb21175ed35a4d31ec90 /lib/error_highlight
parent23c8bc367c6d700789a4059b831606966efb674c (diff)
downloadruby-5fd5d71a4b100fdeca55352a5441b095a1d82e16.tar.gz
[ruby/error_highlight] Support a file that has no final newline
https://github.com/ruby/error_highlight/commit/9d671284cb
Diffstat (limited to 'lib/error_highlight')
-rw-r--r--lib/error_highlight/base.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/error_highlight/base.rb b/lib/error_highlight/base.rb
index fc23508a5d..696df76ff9 100644
--- a/lib/error_highlight/base.rb
+++ b/lib/error_highlight/base.rb
@@ -35,6 +35,7 @@ module ErrorHighlight
@fetch = -> (lineno, last_lineno = lineno) do
snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("")
+ snippet += "\n" unless snippet.end_with?("\n")
# It require some work to support Unicode (or multibyte) characters.
# Tentatively, we stop highlighting if the code snippet has non-ascii characters.