]> git.lizzy.rs Git - micro.git/commitdiff
Apply basename option in tabbar as well
authorZachary Yedidia <zyedidia@gmail.com>
Mon, 24 Feb 2020 18:48:37 +0000 (13:48 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Mon, 24 Feb 2020 18:48:37 +0000 (13:48 -0500)
internal/buffer/buffer.go
internal/display/statusline.go
runtime/help/options.md

index 0ad09a7e48b9bf83094b5ba53530f89400e348a9..a89edc99ecdb8e8fe40362d4cd8919de12310971 100644 (file)
@@ -9,6 +9,7 @@ import (
        "io/ioutil"
        "log"
        "os"
+       "path"
        "path/filepath"
        "strconv"
        "strings"
@@ -363,13 +364,17 @@ func (b *Buffer) Fini() {
 // GetName returns the name that should be displayed in the statusline
 // for this buffer
 func (b *Buffer) GetName() string {
-       if b.name == "" {
+       name := b.name
+       if name == "" {
                if b.Path == "" {
                        return "No name"
                }
-               return b.Path
+               name = b.Path
        }
-       return b.name
+       if b.Settings["basename"].(bool) {
+               return path.Base(name)
+       }
+       return name
 }
 
 //SetName changes the name for this buffer
index c55be9885e0668a6c880161a373ef3266aae73ee..c84215dbd935ada776411f0f0add7c37a43a0aeb 100644 (file)
@@ -3,7 +3,6 @@ package display
 import (
        "bytes"
        "fmt"
-       "path"
        "regexp"
        "strconv"
        "strings"
@@ -32,9 +31,6 @@ type StatusLine struct {
 
 var statusInfo = map[string]func(*buffer.Buffer) string{
        "filename": func(b *buffer.Buffer) string {
-               if b.Settings["basename"].(bool) {
-                       return path.Base(b.GetName())
-               }
                return b.GetName()
        },
        "line": func(b *buffer.Buffer) string {
index 6ce5f4be592da475ec5669dbb210e44f8a628424..709bd5da7b2fdedcfd4b8916b50533fe7b5ffd13 100644 (file)
@@ -44,8 +44,8 @@ Here are the available options:
 
     default value: `true`
 
-* `basename`: in the infobar, show only the basename of the file being edited
-   rather than the full path.
+* `basename`: in the infobar and tabbar, show only the basename of the file
+   being edited rather than the full path.
 
     default value: `false`