Comment 29 for bug 328235

Revision history for this message
Maxime Jayat (maxime-jayat) wrote :

Hey, since it has bothered me for a long time, I've worked on that bug.

There are two problems that I have fixed in two different commits pushed in my branch:

Problem 1:
Steps to reproduce:
-New window
-Split vertically
-Split both terminals horizontally
-Drag the left horizontal split down (by a large amount, or you may fall into problem 2).
-alt-up from the bottom-left terminal goes to the top-right terminal (all other terminal switches are correct)

I've tracked it down to a sign error in the offset calculation between terminals (get_nav_offset), it is fixed in the first commit.

Problem 2:
Steps to reproduce:
-New window
-Make sure the "terminal separator size" in the preferences is higher than 1. The higher, the easier to reproduce.
-Split horizontally
-Split both terminals vertically
-Drag the top vertical split one or two pixels to the left (less than the separator size).
-alt-right from to bottom-left goes to top-right, and alt-left from top-right goes to bottom-left.

The problem can also be reproduced when splitting vertically first, but then problem 1 also occurs and interacts with it, so the behaviour is different.

The bug here is more of an algorithm problem (see Window.navigate_terminal).
To do alt-right (all other directions work the same):
1-we build a list of all terminals which left edge is on the right of the right edge of the current terminal (get_nav_possible)
2-for each of those, we measure the horizontal distance between the current right edge and the left edge of the candidate terminal.
3-we sort the list of the measures and we switch to the terminal with the lowest distance. In case of tie, we use the position of the cursor for the tie break.

When reproducing, when you drag the top split one or two pixels to the left, you reduce the horizontal distance between bottom-left and top-right without invalidating the get_nav_possible test. So the chosen terminal is probably not the one expected by the user.

In my second commit, I have changed the get_nav_possible test so that only terminals which are on the same line or column as the current terminal are candidates for selection.

Please consider merging these fixes, I've been using them for some time without any issue.