Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
e2e8d94b
Unverified
Commit
e2e8d94b
authored
4 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Kill input command on terminate
Fix #2381 Close #2382
parent
4f9a7f8c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/constants.go
+1
-0
1 addition, 0 deletions
src/constants.go
src/core.go
+5
-1
5 additions, 1 deletion
src/core.go
src/terminal.go
+18
-15
18 additions, 15 deletions
src/terminal.go
with
24 additions
and
16 deletions
src/constants.go
+
1
−
0
View file @
e2e8d94b
...
...
@@ -73,6 +73,7 @@ const (
EvtSearchFin
EvtHeader
EvtReady
EvtQuit
)
const
(
...
...
This diff is collapsed.
Click to expand it.
src/core.go
+
5
−
1
View file @
e2e8d94b
...
...
@@ -254,7 +254,11 @@ func Run(opts *Options, version string, revision string) {
}
for
evt
,
value
:=
range
*
events
{
switch
evt
{
case
EvtQuit
:
if
reading
{
reader
.
terminate
()
}
os
.
Exit
(
value
.
(
int
))
case
EvtReadNew
,
EvtReadFin
:
if
evt
==
EvtReadFin
&&
nextCommand
!=
nil
{
restart
(
*
nextCommand
)
...
...
This diff is collapsed.
Click to expand it.
src/terminal.go
+
18
−
15
View file @
e2e8d94b
...
...
@@ -1826,7 +1826,7 @@ func (t *Terminal) killPreview(code int) {
case
t
.
killChan
<-
code
:
default
:
if
code
!=
exitCancel
{
os
.
Exit
(
code
)
t
.
eventBox
.
Set
(
EvtQuit
,
code
)
}
}
}
...
...
@@ -1835,6 +1835,16 @@ func (t *Terminal) cancelPreview() {
t
.
killPreview
(
exitCancel
)
}
func
(
t
*
Terminal
)
exit
(
getCode
func
()
int
)
{
t
.
tui
.
Close
()
code
:=
getCode
()
if
code
<=
exitNoMatch
&&
t
.
history
!=
nil
{
t
.
history
.
append
(
string
(
t
.
input
))
}
// prof.Stop()
t
.
killPreview
(
code
)
}
// Loop is called to start Terminal I/O
func
(
t
*
Terminal
)
Loop
()
{
// prof := profile.Start(profile.ProfilePath("/tmp/"))
...
...
@@ -2010,7 +2020,7 @@ func (t *Terminal) Loop() {
case
code
:=
<-
t
.
killChan
:
if
code
!=
exitCancel
{
util
.
KillCommand
(
cmd
)
os
.
Exit
(
code
)
t
.
eventBox
.
Set
(
EvtQuit
,
code
)
}
else
{
timer
:=
time
.
NewTimer
(
previewCancelWait
)
select
{
...
...
@@ -2047,16 +2057,6 @@ func (t *Terminal) Loop() {
}()
}
exit
:=
func
(
getCode
func
()
int
)
{
t
.
tui
.
Close
()
code
:=
getCode
()
if
code
<=
exitNoMatch
&&
t
.
history
!=
nil
{
t
.
history
.
append
(
string
(
t
.
input
))
}
// prof.Stop()
t
.
killPreview
(
code
)
}
refreshPreview
:=
func
(
command
string
)
{
if
len
(
command
)
>
0
&&
t
.
isPreviewEnabled
()
{
_
,
list
:=
t
.
buildPlusList
(
command
,
false
)
...
...
@@ -2108,12 +2108,13 @@ func (t *Terminal) Loop() {
case
reqRedraw
:
t
.
redraw
()
case
reqClose
:
exit
(
func
()
int
{
t
.
exit
(
func
()
int
{
if
t
.
output
()
{
return
exitOk
}
return
exitNoMatch
})
return
case
reqPreviewDisplay
:
result
:=
value
.
(
previewResult
)
if
t
.
previewer
.
version
!=
result
.
version
{
...
...
@@ -2134,12 +2135,14 @@ func (t *Terminal) Loop() {
t
.
previewer
.
version
=
value
.
(
int64
)
t
.
printPreviewDelayed
()
case
reqPrintQuery
:
exit
(
func
()
int
{
t
.
exit
(
func
()
int
{
t
.
printer
(
string
(
t
.
input
))
return
exitOk
})
return
case
reqQuit
:
exit
(
func
()
int
{
return
exitInterrupt
})
t
.
exit
(
func
()
int
{
return
exitInterrupt
})
return
}
}
t
.
refresh
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment