Skip to content

Commit

Permalink
Add .rb extension to tempfile in vi mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DylanGriffith committed Nov 15, 2024
1 parent 3ceba3b commit 5b1ce32
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5b1ce32

Please sign in to comment.