@@ -18,13 +18,27 @@ export async function init(
18
18
( denops , bufnr , range ) =>
19
19
doRebase ( denops , bufnr , range , gatherCandidates ) ,
20
20
) ;
21
+ await define (
22
+ denops ,
23
+ bufnr ,
24
+ "rebase:x" ,
25
+ ( denops , bufnr , range ) =>
26
+ doRebase ( denops , bufnr , range , gatherCandidates , true ) ,
27
+ ) ;
21
28
await define (
22
29
denops ,
23
30
bufnr ,
24
31
"rebase:i" ,
25
32
( denops , bufnr , range ) =>
26
33
doRebaseInteractive ( denops , bufnr , range , gatherCandidates ) ,
27
34
) ;
35
+ await define (
36
+ denops ,
37
+ bufnr ,
38
+ "rebase:i:x" ,
39
+ ( denops , bufnr , range ) =>
40
+ doRebaseInteractive ( denops , bufnr , range , gatherCandidates , true ) ,
41
+ ) ;
28
42
await define (
29
43
denops ,
30
44
bufnr ,
@@ -40,16 +54,26 @@ async function doRebase(
40
54
bufnr : number ,
41
55
range : Range ,
42
56
gatherCandidates : GatherCandidates < Candidate > ,
57
+ execute ?: boolean ,
43
58
) : Promise < void > {
44
59
const xs = await gatherCandidates ( denops , bufnr , range ) ;
45
60
const x = xs . at ( 0 ) ;
46
61
if ( ! x ) {
47
62
return ;
48
63
}
49
- await denops . dispatch ( "gin" , "command" , "" , [
50
- "rebase" ,
51
- x . commit ,
52
- ] ) ;
64
+ const args = [ "rebase" , x . commit ] ;
65
+ if ( execute ) {
66
+ const cmd = await helper . input ( denops , {
67
+ prompt : "Execute command after rebase: " ,
68
+ } ) ?? "" ;
69
+ await denops . cmd ( 'redraw | echo ""' ) ;
70
+ if ( ! cmd ) {
71
+ await helper . echoerr ( denops , "Cancelled" ) ;
72
+ return ;
73
+ }
74
+ args . push ( "-x" , cmd ) ;
75
+ }
76
+ await denops . dispatch ( "gin" , "command" , "" , args ) ;
53
77
54
78
// suppress false-positive detection of file changes
55
79
await denops . cmd ( "silent checktime" ) ;
@@ -60,20 +84,33 @@ async function doRebaseInteractive(
60
84
bufnr : number ,
61
85
range : Range ,
62
86
gatherCandidates : GatherCandidates < Candidate > ,
87
+ execute ?: boolean ,
63
88
) : Promise < void > {
64
89
const xs = await gatherCandidates ( denops , bufnr , range ) ;
65
90
const x = xs . at ( 0 ) ;
66
91
if ( ! x ) {
67
92
return ;
68
93
}
69
- // NOTE:
70
- // We must NOT await the command otherwise Vim would freeze
71
- // because command proxy could not work if we await here.
72
- denops . dispatch ( "gin" , "command" , "" , [
94
+ const args = [
73
95
"rebase" ,
74
96
"--interactive" ,
75
97
x . commit ,
76
- ] ) . catch ( async ( e ) => {
98
+ ] ;
99
+ if ( execute ) {
100
+ const cmd = await helper . input ( denops , {
101
+ prompt : "Execute command after rebase: " ,
102
+ } ) ?? "" ;
103
+ await denops . cmd ( 'redraw | echo ""' ) ;
104
+ if ( ! cmd ) {
105
+ await helper . echoerr ( denops , "Cancelled" ) ;
106
+ return ;
107
+ }
108
+ args . push ( "-x" , cmd ) ;
109
+ }
110
+ // NOTE:
111
+ // We must NOT await the command otherwise Vim would freeze
112
+ // because command proxy could not work if we await here.
113
+ denops . dispatch ( "gin" , "command" , "" , args ) . catch ( async ( e ) => {
77
114
await helper . echoerr ( denops , e . toString ( ) ) ;
78
115
} ) . then (
79
116
// suppress false-positive detection of file changes
0 commit comments