Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/display/tabwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
for i, n := range w.Names {
x++
s := util.CharacterCountInString(n)
if vloc.Y == w.Y && vloc.X < x+s {
if vloc.Y == w.Y && vloc.X < x+s+2 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes a side effect: when clicking on the empty space after the last tab, it activates the last tab if the click is 1 or 2 (but not 3 or more) spaces after the last tab name.

Also a note unrelated to this PR: it seems pointless to check vloc.Y == w.Y at each iteration of the loop, we can just check it at the beginning.

So, how about such change:

diff --git a/internal/display/tabwindow.go b/internal/display/tabwindow.go
index 423b966b..96aead73 100644
--- a/internal/display/tabwindow.go
+++ b/internal/display/tabwindow.go
@@ -29,12 +29,19 @@ func (w *TabWindow) Resize(width, height int) {
 }
 
 func (w *TabWindow) LocFromVisual(vloc buffer.Loc) int {
+	if vloc.Y != w.Y {
+		return -1
+	}
+
 	x := -w.hscroll
 
 	for i, n := range w.Names {
 		x++
 		s := util.CharacterCountInString(n)
-		if vloc.Y == w.Y && vloc.X < x+s+2 {
+		if vloc.X < x+s {
+			return i
+		}
+		if i < len(w.Names)-1 && vloc.X < x+s+2 {
 			return i
 		}
 		x += s

Copy link
Collaborator

@JoeKar JoeKar Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes a side effect: when clicking on the empty space after the last tab, it activates the last tab if the click is 1 or 2 (but not 3 or more) spaces after the last tab name.

Here I'm quite undecided.
When we have 3 tabs (a, b & c) open then we can activate:

  • a+2
  • 2+b+2
  • 2+c

Clicking on the left side of a is limited by the boundary of the window, but the right side of c most probably isn't.
Now we have a active and click slightly of the right side after c then c it isn't activated.
We could activate c with the whole remaining space (by adding a check for i == len(w.Names)-1 at the end of the loop and return i too). What do you think?

While we are here already, then we should also fix the use case of wide runes in tab names (also note in #3516) by exchanging all util.CharacterCountInString() to runewidth.StringWidth() to proper address the x position and scroll width.

return i
}
x += s
Expand Down