mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
Fixup ActivatePaneDirection to respect edge intersection
d2892c6
switched to using recency only, but neglected to verify that
the edges of the candidate panes were actually touching, leading to
some weird results.
This commit uses recency only when the edges intersect, otherwise,
scores 0 for the candidate.
refs: #2374
This commit is contained in:
parent
cb09e71214
commit
cb75b642f7
@ -5,6 +5,7 @@ use crate::{Mux, WindowId};
|
|||||||
use bintree::PathBranch;
|
use bintree::PathBranch;
|
||||||
use config::configuration;
|
use config::configuration;
|
||||||
use config::keyassignment::PaneDirection;
|
use config::keyassignment::PaneDirection;
|
||||||
|
use rangeset::intersects_range;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::cell::{RefCell, RefMut};
|
use std::cell::{RefCell, RefMut};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -1276,31 +1277,51 @@ impl Tab {
|
|||||||
|
|
||||||
let recency = self.recency.borrow();
|
let recency = self.recency.borrow();
|
||||||
|
|
||||||
|
fn edge_intersects(
|
||||||
|
active_start: usize,
|
||||||
|
active_size: usize,
|
||||||
|
current_start: usize,
|
||||||
|
current_size: usize,
|
||||||
|
) -> bool {
|
||||||
|
intersects_range(
|
||||||
|
&(active_start..active_start + active_size),
|
||||||
|
&(current_start..current_start + current_size),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
for pane in &panes {
|
for pane in &panes {
|
||||||
let score = match direction {
|
let score = match direction {
|
||||||
PaneDirection::Right => {
|
PaneDirection::Right => {
|
||||||
if pane.left == active.left + active.width + 1 {
|
if pane.left == active.left + active.width + 1
|
||||||
|
&& edge_intersects(active.top, active.height, pane.top, pane.height)
|
||||||
|
{
|
||||||
1 + recency.score(pane.index)
|
1 + recency.score(pane.index)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PaneDirection::Left => {
|
PaneDirection::Left => {
|
||||||
if pane.left + pane.width + 1 == active.left {
|
if pane.left + pane.width + 1 == active.left
|
||||||
|
&& edge_intersects(active.top, active.height, pane.top, pane.height)
|
||||||
|
{
|
||||||
1 + recency.score(pane.index)
|
1 + recency.score(pane.index)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PaneDirection::Up => {
|
PaneDirection::Up => {
|
||||||
if pane.top + pane.height + 1 == active.top {
|
if pane.top + pane.height + 1 == active.top
|
||||||
|
&& edge_intersects(active.left, active.width, pane.left, pane.width)
|
||||||
|
{
|
||||||
1 + recency.score(pane.index)
|
1 + recency.score(pane.index)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PaneDirection::Down => {
|
PaneDirection::Down => {
|
||||||
if active.top + active.height + 1 == pane.top {
|
if active.top + active.height + 1 == pane.top
|
||||||
|
&& edge_intersects(active.left, active.width, pane.left, pane.width)
|
||||||
|
{
|
||||||
1 + recency.score(pane.index)
|
1 + recency.score(pane.index)
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
|
Loading…
Reference in New Issue
Block a user