diff --git a/denops/gin/action/rebase.ts b/denops/gin/action/rebase.ts index a2a1e46a..f4d7d39e 100644 --- a/denops/gin/action/rebase.ts +++ b/denops/gin/action/rebase.ts @@ -25,6 +25,13 @@ export async function init( (denops, bufnr, range) => doRebaseInteractive(denops, bufnr, range, gatherCandidates), ); + await define( + denops, + bufnr, + "rebase:instant-drop", + (denops, bufnr, range) => + doRebaseInstantDrop(denops, bufnr, range, gatherCandidates), + ); }); } @@ -74,3 +81,26 @@ async function doRebaseInteractive( () => denops.cmd("silent checktime"), ); } + +async function doRebaseInstantDrop( + denops: Denops, + bufnr: number, + range: Range, + gatherCandidates: GatherCandidates, +): Promise { + const xs = await gatherCandidates(denops, bufnr, range); + const x = xs.at(0); + if (!x) { + return; + } + await denops.dispatch("gin", "command", "", [ + "rebase", + "--onto", + `${x.commit}~`, + x.commit, + "HEAD", + ]); + + // suppress false-positive detection of file changes + await denops.cmd("silent checktime"); +}