aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2021-03-04 09:31:23 +0100
committerPetter Rodhelind <petter.rodhelind@gmail.com>2021-03-04 09:31:28 +0100
commit666d2301e7d09531068fe9898f7779c9affebb70 (patch)
treebef121e654ddbb71146bca9f915d7e532ad8f76c
parent41009a3bbf367bab2bb6140ed0d71860be4e998b (diff)
downloadpoe-666d2301e7d09531068fe9898f7779c9affebb70.tar.gz
poe-666d2301e7d09531068fe9898f7779c9affebb70.tar.bz2
poe-666d2301e7d09531068fe9898f7779c9affebb70.zip
Add trailing separator to dirs tag without changing the actual name.
The previous commit which added the trailing slash introduced a bug, where the "do not open the same buffer again if it already exists" stopped working because the actual file name did not match what was requested.
-rw-r--r--editor/buffer.go8
-rw-r--r--ui/tcell/window.go7
2 files changed, 11 insertions, 4 deletions
diff --git a/editor/buffer.go b/editor/buffer.go
index 503cf02..9b7444a 100644
--- a/editor/buffer.go
+++ b/editor/buffer.go
@@ -110,6 +110,11 @@ func (b *Buffer) ReadFile() error {
return nil
}
+// IsDir returns true if the type of the this buffer is a directory listing.
+func (b *Buffer) IsDir() bool {
+ return b.what == BufferDir
+}
+
// SaveFile writes content of buffer to its filename.
func (b *Buffer) SaveFile() (int, error) {
b.initBuffer()
@@ -176,9 +181,6 @@ func (b *Buffer) Name() string {
return ""
}
s, _ := filepath.Abs(b.file.name)
- if b.what == BufferDir {
- s += string(filepath.Separator)
- }
return s
}
diff --git a/ui/tcell/window.go b/ui/tcell/window.go
index 86f9ce4..b6378be 100644
--- a/ui/tcell/window.go
+++ b/ui/tcell/window.go
@@ -2,6 +2,7 @@ package uitcell
import (
"fmt"
+ "path/filepath"
tcell "github.com/gdamore/tcell/v2"
"github.com/prodhe/poe/editor"
@@ -41,8 +42,12 @@ func NewWindow(id int64) *Window {
},
}
+ tagname := win.TagName()
+ if win.body.text.IsDir() {
+ tagname += string(filepath.Separator)
+ }
fmt.Fprintf(win.tagline, "%s Del Get ",
- win.TagName(),
+ tagname,
)
return win