From 079f17b763696e2fc6a53f6baa13faa481cfe501 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 13 Sep 2014 21:50:17 -0400 Subject: [PATCH] Fix off-by-one error when opening editor from the grep view --- NEWS.adoc | 3 ++- src/grep.c | 2 +- test/grep/editor-test | 45 +++++++++++++++++++++++++++++++++++++++++++++ test/tools/libtest.sh | 19 ++++++++++++++++++- 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100755 test/grep/editor-test diff --git a/NEWS.adoc b/NEWS.adoc index c078f70..678cea8 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -12,7 +12,8 @@ Improvements: Bug fixes: - Update manual to reflect default keybinding changes. (GH #325) - - Improve graph support for `--first-parent`. (GH #326) + - Fix graph support for `--first-parent`. (GH #326) + - Fix off-by-one error when opening editor from the grep view. tig-2.0.3 --------- diff --git a/src/grep.c b/src/grep.c index 6db231c..5e671cc 100644 --- a/src/grep.c +++ b/src/grep.c @@ -181,7 +181,7 @@ grep_request(struct view *view, enum request request, struct line *line) case REQ_EDIT: if (!*grep->file) return request; - open_editor(grep->file, grep->lineno); + open_editor(grep->file, grep->lineno + 1); return REQ_NONE; case REQ_VIEW_BLAME: diff --git a/test/grep/editor-test b/test/grep/editor-test new file mode 100755 index 0000000..42492ee --- /dev/null +++ b/test/grep/editor-test @@ -0,0 +1,45 @@ +#!/bin/sh + +. libtest.sh +. libgit.sh + +export LINES=16 + +tigrc < "$fake_editor" <> "$HOME/editor.log" +sed -n -e "\${lineno}p" "\$file" >> "$HOME/editor.log" +EOF + +chmod +x "$fake_editor" +export EDITOR="$(basename "$fake_editor")" +export PATH="$(dirname "$fake_editor"):$PATH" + cd "$output_dir" # -- 2.11.4.GIT