Skip to content

Commit 8a826cb

Browse files
authored
Merge pull request #151 from atusy/feat-instant-drop
👍 add rebase:instant-drop action
2 parents 8158189 + 1842c2d commit 8a826cb

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

denops/gin/action/rebase.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ export async function init(
2525
(denops, bufnr, range) =>
2626
doRebaseInteractive(denops, bufnr, range, gatherCandidates),
2727
);
28+
await define(
29+
denops,
30+
bufnr,
31+
"rebase:instant-drop",
32+
(denops, bufnr, range) =>
33+
doRebaseInstantDrop(denops, bufnr, range, gatherCandidates),
34+
);
2835
});
2936
}
3037

@@ -74,3 +81,26 @@ async function doRebaseInteractive(
7481
() => denops.cmd("silent checktime"),
7582
);
7683
}
84+
85+
async function doRebaseInstantDrop(
86+
denops: Denops,
87+
bufnr: number,
88+
range: Range,
89+
gatherCandidates: GatherCandidates<Candidate>,
90+
): Promise<void> {
91+
const xs = await gatherCandidates(denops, bufnr, range);
92+
const x = xs.at(0);
93+
if (!x) {
94+
return;
95+
}
96+
await denops.dispatch("gin", "command", "", [
97+
"rebase",
98+
"--onto",
99+
`${x.commit}~`,
100+
x.commit,
101+
"HEAD",
102+
]);
103+
104+
// suppress false-positive detection of file changes
105+
await denops.cmd("silent checktime");
106+
}

0 commit comments

Comments
 (0)