From 67899432e106d29a23bd003eff932bd58f4ab2e7 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:32:01 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=91=8D=20add=20optional=20reg=20argum?= =?UTF-8?q?ent=20to=20yank()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/gin/util/yank.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/denops/gin/util/yank.ts b/denops/gin/util/yank.ts index 8a9372e6..41126d4a 100644 --- a/denops/gin/util/yank.ts +++ b/denops/gin/util/yank.ts @@ -5,7 +5,8 @@ import { v } from "https://deno.land/x/denops_std@v5.0.1/variable/mod.ts"; export async function yank( denops: Denops, value: string, + reg?: string, ): Promise { - const reg = await v.get(denops, "register"); + reg = reg ?? await v.get(denops, "register"); await fn.setreg(denops, reg, value); } From b1b6d72484846334bbbc1997494aad6b045d8c7d Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:35:10 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=91=8D=20allow=20specifying=20registe?= =?UTF-8?q?r=20to=20GinBrowser=20++yank?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ++yank -> v:register ++yank=A -> named register A ++yank=+ -> unnamedplus register --- denops/gin/command/browse/command.ts | 12 ++++++++---- denops/gin/command/browse/main.ts | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/denops/gin/command/browse/command.ts b/denops/gin/command/browse/command.ts index ba988a85..c9fbc618 100644 --- a/denops/gin/command/browse/command.ts +++ b/denops/gin/command/browse/command.ts @@ -15,14 +15,14 @@ import { yank } from "../../util/yank.ts"; export type ExecOptions = Omit & { worktree?: string; - yank?: boolean; + yank: string | boolean; noBrowser?: boolean; }; export async function exec( denops: Denops, commitish: string, - options: ExecOptions = {}, + options: ExecOptions = { yank: false }, ): Promise { const [verbose, aliases] = await batch.collect(denops, (denops) => [ option.verbose.get(denops), @@ -56,8 +56,12 @@ export async function exec( aliases, }); - if (options.yank) { - await yank(denops, url.href); + if (options.yank !== false) { + await yank( + denops, + url.href, + options.yank === true ? undefined : options.yank, + ); } if (options.noBrowser) { await denops.cmd("echomsg url", { url: url.href }); diff --git a/denops/gin/command/browse/main.ts b/denops/gin/command/browse/main.ts index d0f17373..dc052dc1 100644 --- a/denops/gin/command/browse/main.ts +++ b/denops/gin/command/browse/main.ts @@ -61,7 +61,7 @@ async function command( ); await exec(denops, commitish ?? "HEAD", { worktree: opts.worktree, - yank: "yank" in opts, + yank: opts.yank === "" ? true : (opts.yank ?? false), noBrowser: ("n" in flags || "no-browser" in flags), remote: ensure(flags.remote, is.OneOf([is.Undefined, is.String]), { "message": "REMOTE in --remote={REMOTE} must be string", From a41c923a50931007bfb246d0d471f28d2a401f04 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:35:37 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=8C=BF=20test=20yank()=20with=20a=20e?= =?UTF-8?q?xplicit=20register?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/gin/util/yank_test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/denops/gin/util/yank_test.ts b/denops/gin/util/yank_test.ts index 01507d95..3062f651 100644 --- a/denops/gin/util/yank_test.ts +++ b/denops/gin/util/yank_test.ts @@ -10,4 +10,11 @@ test("all", "yank", async (denops, t) => { assertEquals(await denops.eval("getreg(v:register)"), "Hello world"); }, }); + await t.step({ + name: "sets the value to the named register a", + fn: async () => { + await yank(denops, "Hello world", "a"); + assertEquals(await denops.eval("getreg('a')"), "Hello world"); + }, + }); }); From ac2d5bc13e59ca5bd4e6443b7ab43582bae336e1 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:42:53 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=93=9D=20document=20GinBrowse=20++yan?= =?UTF-8?q?k=3D{regname}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/gin.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/gin.txt b/doc/gin.txt index 5362308f..9b3a259a 100644 --- a/doc/gin.txt +++ b/doc/gin.txt @@ -177,8 +177,11 @@ COMMANDS *gin-commands* The following options are valid as {++option}: - ++yank + ++yank={regname} Yank the URL to the clipboard. + {regname} is optional and defaults to |v:register|. + If non-empty string is given, the value is passed to the + {regname} argument of |setreg()|. See |gin-commands-options| for common {++option}. From c0ac3585cdcdb625ce92c42ce3e3a19959898da7 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Sat, 11 Nov 2023 00:25:47 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B=20ExecOptions.yank=20should=20?= =?UTF-8?q?be=20optional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/gin/command/browse/command.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/denops/gin/command/browse/command.ts b/denops/gin/command/browse/command.ts index c9fbc618..abe2c358 100644 --- a/denops/gin/command/browse/command.ts +++ b/denops/gin/command/browse/command.ts @@ -15,14 +15,14 @@ import { yank } from "../../util/yank.ts"; export type ExecOptions = Omit & { worktree?: string; - yank: string | boolean; + yank?: string | boolean; noBrowser?: boolean; }; export async function exec( denops: Denops, commitish: string, - options: ExecOptions = { yank: false }, + options: ExecOptions = {}, ): Promise { const [verbose, aliases] = await batch.collect(denops, (denops) => [ option.verbose.get(denops), @@ -56,7 +56,7 @@ export async function exec( aliases, }); - if (options.yank !== false) { + if (options.yank != null && options.yank !== false) { await yank( denops, url.href,