mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 23:05:40 -04:00
Fix non-working split resize with mouse drag (#1811)
Fix the 2nd part of #1773: resize via mouse drag doesn't work if the split on the left contains other splits, i.e. is not a leaf node. The problem is that only leaf nodes have unique id. For non-leaf nodes ID() returns 0. So we shouldn't search the node by id. So replace GetMouseSplitID() with GetMouseSplitNode().
This commit is contained in:
parent
a4cc5a4146
commit
6e43af31cb
@ -220,9 +220,8 @@ func (t *Tab) HandleEvent(event tcell.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if wasReleased {
|
if wasReleased {
|
||||||
resizeID := t.GetMouseSplitID(buffer.Loc{mx, my})
|
t.resizing = t.GetMouseSplitNode(buffer.Loc{mx, my})
|
||||||
if resizeID != 0 {
|
if t.resizing != nil {
|
||||||
t.resizing = t.GetNode(uint64(resizeID))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,32 +53,32 @@ func (w *UIWindow) Display() {
|
|||||||
w.drawNode(w.root)
|
w.drawNode(w.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *UIWindow) GetMouseSplitID(vloc buffer.Loc) uint64 {
|
func (w *UIWindow) GetMouseSplitNode(vloc buffer.Loc) *views.Node {
|
||||||
var mouseLoc func(*views.Node) uint64
|
var mouseLoc func(*views.Node) *views.Node
|
||||||
mouseLoc = func(n *views.Node) uint64 {
|
mouseLoc = func(n *views.Node) *views.Node {
|
||||||
cs := n.Children()
|
cs := n.Children()
|
||||||
for i, c := range cs {
|
for i, c := range cs {
|
||||||
if c.Kind == views.STVert {
|
if c.Kind == views.STVert {
|
||||||
if i != len(cs)-1 {
|
if i != len(cs)-1 {
|
||||||
if vloc.X == c.X+c.W && vloc.Y >= c.Y && vloc.Y < c.Y+c.H {
|
if vloc.X == c.X+c.W && vloc.Y >= c.Y && vloc.Y < c.Y+c.H {
|
||||||
return c.ID()
|
return c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if c.Kind == views.STHoriz {
|
} else if c.Kind == views.STHoriz {
|
||||||
if i != len(cs)-1 {
|
if i != len(cs)-1 {
|
||||||
if vloc.Y == c.Y+c.H-1 && vloc.X >= c.X && vloc.X < c.X+c.W {
|
if vloc.Y == c.Y+c.H-1 && vloc.X >= c.X && vloc.X < c.X+c.W {
|
||||||
return c.ID()
|
return c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, c := range cs {
|
for _, c := range cs {
|
||||||
m := mouseLoc(c)
|
m := mouseLoc(c)
|
||||||
if m != 0 {
|
if m != nil {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return nil
|
||||||
}
|
}
|
||||||
return mouseLoc(w.root)
|
return mouseLoc(w.root)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user