From 1ab493de5904652ea2b2f2c39e92b54e6527b11e Mon Sep 17 00:00:00 2001 From: Camille Date: Fri, 10 Aug 2018 22:54:19 +0200 Subject: [PATCH] Only show basename of file in tabs unless there are mutliple tabs with the same basename (fixes #1079) (#1081) * Only show basename of file in tabs unless there are mutliple tabs with the same basename (fixes #1079) * Small fix --- cmd/micro/tab.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/micro/tab.go b/cmd/micro/tab.go index 0998779a..88c260a6 100644 --- a/cmd/micro/tab.go +++ b/cmd/micro/tab.go @@ -1,6 +1,7 @@ package main import ( + "path/filepath" "sort" "github.com/zyedidia/tcell" @@ -97,14 +98,26 @@ func CurView() *View { func TabbarString() (string, map[int]int) { str := "" indicies := make(map[int]int) + unique := make(map[string]int) + + for _, t := range tabs { + unique[filepath.Base(t.Views[t.CurView].Buf.GetName())]++ + } + for i, t := range tabs { + buf := t.Views[t.CurView].Buf + name := filepath.Base(buf.GetName()) + if i == curTab { str += "[" } else { str += " " } - buf := t.Views[t.CurView].Buf - str += buf.GetName() + if unique[name] == 1 { + str += name + } else { + str += buf.GetName() + } if buf.Modified() { str += " +" } @@ -113,8 +126,9 @@ func TabbarString() (string, map[int]int) { } else { str += " " } - indicies[Count(str)-1] = i + 1 str += " " + + indicies[Count(str)-2] = i + 1 } return str, indicies }