summaryrefslogtreecommitdiff
path: root/viewport
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-05-02 19:08:49 +0200
committerewy <ewy0@protonmail.com>2026-05-02 19:08:49 +0200
commitd1633e905a1487e8845088c03db8faf53d587e46 (patch)
tree38024375e7bc7a826b4c382c246ec7668f96ab46 /viewport
parentaa9031ab0deb1535875fe3ca2530428f485dbf9d (diff)
trim right side space in viewport
Diffstat (limited to 'viewport')
-rw-r--r--viewport/viewport.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/viewport/viewport.go b/viewport/viewport.go
index 7b897e7..da7832e 100644
--- a/viewport/viewport.go
+++ b/viewport/viewport.go
@@ -17,7 +17,15 @@ func Process(input string, height int) string {
cropped, top, bottom := Crop(input, lines, height)
return WithScroll(cropped, int(top*float32(height)), int(bottom*float32(height)))
}
- return input
+ return TrimSpaceRight(input)
+}
+
+func TrimSpaceRight(input string) string {
+ lines := strings.Split(input, "\n")
+ for i, l := range lines {
+ lines[i] = strings.TrimRight(l, " ")
+ }
+ return strings.Join(lines, "\n")
}
func Focus(lines []string, needle string) int {