mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-27 03:10:24 +00:00
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
This commit is contained in:
parent
f56621a4bd
commit
1ab493de59
1 changed files with 17 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue