From 5fd5d71a4b100fdeca55352a5441b095a1d82e16 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 13 Jul 2021 16:53:52 +0900 Subject: [ruby/error_highlight] Support a file that has no final newline https://github.com/ruby/error_highlight/commit/9d671284cb --- lib/error_highlight/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/error_highlight') 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. -- cgit v1.2.3