Skip to content

Commit f793085

Browse files
Merge branch 'master' into dev
2 parents 3aa5e19 + 1f71667 commit f793085

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

cmd/micro/micro.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ func DoEvent() {
422422
b.AutoSave()
423423
}
424424
case <-shell.CloseTerms:
425+
action.Tabs.CloseTerms()
425426
case event = <-screen.Events:
426427
case <-screen.DrawChan():
427428
for len(screen.DrawChan()) > 0 {

internal/action/tab.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ func (t *TabList) ResetMouse() {
188188
}
189189
}
190190

191+
// CloseTerms notifies term panes that a terminal job has finished.
192+
func (t *TabList) CloseTerms() {
193+
for _, tab := range t.List {
194+
for _, p := range tab.Panes {
195+
if tp, ok := p.(*TermPane); ok {
196+
tp.HandleTermClose()
197+
}
198+
}
199+
}
200+
}
201+
191202
// Tabs is the global tab list
192203
var Tabs *TabList
193204

internal/action/termpane.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ func (t *TermPane) HandleEvent(event tcell.Event) {
159159
if t.Status != shell.TTDone {
160160
t.WriteString(event.EscSeq())
161161
}
162-
} else if e, ok := event.(*tcell.EventMouse); e != nil && (!ok || t.State.Mode(terminal.ModeMouseMask)) {
162+
} else if e, ok := event.(*tcell.EventMouse); !ok || t.State.Mode(terminal.ModeMouseMask) {
163163
// t.WriteString(event.EscSeq())
164-
} else if e != nil {
164+
} else {
165165
x, y := e.Position()
166166
v := t.GetView()
167167
x -= v.X
@@ -188,7 +188,12 @@ func (t *TermPane) HandleEvent(event tcell.Event) {
188188
t.mouseReleased = true
189189
}
190190
}
191+
}
191192

193+
// HandleTermClose is called when a terminal has finished its job
194+
// and should be closed. If that terminal is this termpane's terminal,
195+
// HandleTermClose will close the terminal and the termpane itself.
196+
func (t *TermPane) HandleTermClose() {
192197
if t.Status == shell.TTClose {
193198
t.Quit()
194199
}

0 commit comments

Comments
 (0)