{"thread":{"id":"17521","subject":"[tig PATCH] treat empty '/' as \"find next\"","startedAt":"2009-02-03T05:49:08Z","lastAt":"2009-02-04T09:02:56Z","messageCount":2,"participants":["Jeff King","Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102921","messageId":"20090203054907.GA21695@sigill.intra.peff.net","threadId":"17521","inReplyTo":null,"subject":"[tig PATCH] treat empty '/' as \"find next\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-03T05:49:08Z","receivedAt":"2009-02-03T05:49:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When the user requests a forward or backwards search, if\nthey provide no search string then we just abort the search.\nHowever, many other programs (such as less and vi) treat\nthis as \"repeat the last search\", so users may have their\nfingers trained to do this rather than use the explicit\n\"find next\" feature.\n\nThis patch causes tig, if there was a previous search, to\nfind the next (or previous, if \"?\" was used) match in such a\ncase.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI tried retraining my fingers, but they just won't do it. :)\n\nRelated is the fact that searching for \"foo\", followed by another search\nfor \"foo\" will find the same line. That is, the second search won't move\nat all, which is not the case for \"less\". I'm not sure what is the right\nmental model for that behavior:\n\n  1. Searches always start at line n+1\n\n  2. There is a special case for searching for the thing we last\n     matched, which by definition we already know is on the current\n     line.\n\n\"less\" seems to implement (1). That is, if you do this:\n\n for i in one two three; do echo $i line; done | less\n\nentering \"/two\" will take you the second line. Entering \"/line\" after\nthat will take you to the _third_ line. This is mostly intuitive, since\nyou have already looked at the current line and want to search forward.\nBut it is confusing if you try \"/one\" on the first line: you get\n\"pattern not found\" since it is not in any line after the first (but you\nare searching because you haven't even looked at the first line).\n\nSo in some ways tig's behavior is better, and in some ways worse. And I\nhave to admit, my main reason for \"/foo\" followed by \"/foo\" was that\njust using \"/\" for the second one didn't work. Which the patch below\nshould deal with.\n\n tig.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/tig.c b/tig.c\nindex b4e4b59..c02f71b 100644\n--- a/tig.c\n+++ b/tig.c\n@@ -6812,6 +6812,10 @@ main(int argc, const char *argv[])\n \n \t\t\tif (search)\n \t\t\t\tstring_ncopy(opt_search, search, strlen(search));\n+\t\t\telse if (*opt_search)\n+\t\t\t\trequest = request == REQ_SEARCH ?\n+\t\t\t\t\tREQ_FIND_NEXT :\n+\t\t\t\t\tREQ_FIND_PREV;\n \t\t\telse\n \t\t\t\trequest = REQ_NONE;\n \t\t\tbreak;\n-- \n1.6.1.2.465.g1dfd1\n"},{"id":"103090","messageId":"2c6b72b30902040102i13dbb667q631dee22a5735fc@mail.gmail.com","threadId":"17521","inReplyTo":"20090203054907.GA21695@sigill.intra.peff.net","subject":"Re: [tig PATCH] treat empty '/' as \"find next\"","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2009-02-04T09:02:56Z","receivedAt":"2009-02-04T09:02:56Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"On Tue, Feb 3, 2009 at 06:49, Jeff King <peff@peff.net> wrote:\n> This patch causes tig, if there was a previous search, to\n> find the next (or previous, if \"?\" was used) match in such a\n> case.\n\nThanks, makes sense.\n\n-- \nJonas Fonseca\n"}]}