Skip to content

Commit

Permalink
Fix: Opening files from diff line when not in project root (#393)
Browse files Browse the repository at this point in the history
When trying to open a file from gd in $EDITOR (alt + e) the wrong file
was being opened when the command wasn't executed from the repository's
root directory.
  • Loading branch information
sandr01d committed Apr 27, 2024
1 parent 6f212fd commit b35b309
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ _forgit_diff_view() {
}

_forgit_edit_diffed_file() {
local input_line=$1
local input_line rootdir
input_line=$1
rootdir=$(git rev-parse --show-toplevel)
filename=$(echo "$input_line" | _forgit_get_single_file_from_diff_line)
$EDITOR "$filename" >/dev/tty </dev/tty
$EDITOR "$rootdir/$filename" >/dev/tty </dev/tty
}

_forgit_diff_enter() {
Expand Down

0 comments on commit b35b309

Please sign in to comment.