From 3422d8211cfb2e002f9801ac285cd06fbf1ff169 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 9 May 2012 21:56:13 -0400 Subject: [PATCH] Do not count the first line and parent accessor lines in the tree view --- tig.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tig.c b/tig.c index 2e290b2..b47cc7b 100644 --- a/tig.c +++ b/tig.c @@ -4493,6 +4493,8 @@ push_tree_stack_entry(const char *name, unsigned long lineno) #define TREE_ID_OFFSET \ STRING_SIZE("100644 blob ") +#define tree_entry_is_parent(entry) (!strcmp("..", (entry)->name)) + struct tree_entry { char id[SIZEOF_REV]; mode_t mode; @@ -4570,6 +4572,8 @@ tree_entry(struct view *view, enum line_type type, const char *path, entry->mode = strtoul(mode, NULL, 8); if (id) string_copy_rev(entry->id, id); + if (type == LINE_TREE_HEAD || tree_entry_is_parent(entry)) + view->lineoffset++; return line; } @@ -4695,6 +4699,9 @@ tree_read(struct view *view, char *text) return TRUE; } + if (tree_lineno <= view->pos.lineno) + tree_lineno = view->lineoffset; + if (tree_lineno > view->pos.lineno) { view->pos.lineno = tree_lineno; tree_lineno = 0; @@ -4848,12 +4855,19 @@ tree_select(struct view *view, struct line *line) { struct tree_entry *entry = line->data; + if (line->type == LINE_TREE_HEAD) { + string_format(view->ref, "Files in /%s", opt_path); + return; + } + + if (line->type == LINE_TREE_DIR && tree_entry_is_parent(entry)) { + string_copy(view->ref, "Open parent directory"); + return; + } + if (line->type == LINE_TREE_FILE) { string_copy_rev(ref_blob, entry->id); string_format(opt_file, "%s%s", opt_path, tree_path(line)); - - } else if (line->type != LINE_TREE_DIR) { - return; } string_copy_rev(view->ref, entry->id); -- 2.11.4.GIT