From 5b1ce3234f306102c2e5d996919266f027cddca5 Mon Sep 17 00:00:00 2001 From: Dylan Griffith Date: Fri, 15 Nov 2024 14:10:03 -0600 Subject: [PATCH] Add .rb extension to tempfile in vi mode When you are in VI mode and you enter normal mode and press `v` it opens up your `$EDITOR` to edit the current context. The issue is that your `$EDITOR` does not know that you are editing Ruby code so you don't get any syntax highlighting or formatting. This change adds a `.rb` extension to the tempfile opened by the editor which then ensures you get the correct syntax highlighting and formatting. --- lib/reline/line_editor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index c8a7fc9fea..9580402ecd 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2264,7 +2264,7 @@ def finish end private def vi_histedit(key) - path = Tempfile.open { |fp| + path = Tempfile.open(["reline", ".rb"]) { |fp| fp.write whole_lines.join("\n") fp.path }