File tree Expand file tree Collapse file tree 4 files changed +43
-12
lines changed Expand file tree Collapse file tree 4 files changed +43
-12
lines changed Original file line number Diff line number Diff line change 8
8
validateOpts ,
9
9
} from "jsr:@denops/std@^7.0.0/argument" ;
10
10
import { fillCmdArgs , normCmdArgs , parseSilent } from "../../util/cmd.ts" ;
11
+ import { ensurePath } from "../../util/ensure_path.ts" ;
11
12
import { exec } from "./command.ts" ;
12
13
13
14
export function main ( denops : Denops ) : void {
@@ -46,8 +47,8 @@ async function command(
46
47
...builtinOpts ,
47
48
] ) ;
48
49
49
- const [ abspath ] = parseResidue ( residue ) ;
50
- await exec ( denops , abspath , {
50
+ const [ rawpath ] = parseResidue ( residue ) ;
51
+ await exec ( denops , await ensurePath ( denops , rawpath ) , {
51
52
worktree : opts . worktree ,
52
53
opener : opts . opener ,
53
54
noOurs : "no-ours" in opts ,
@@ -60,9 +61,12 @@ async function command(
60
61
61
62
function parseResidue (
62
63
residue : string [ ] ,
63
- ) : [ string ] {
64
- // GinChaperon [{options}] {path}
64
+ ) : [ string | undefined ] {
65
65
switch ( residue . length ) {
66
+ // GinChaperon [{options}]
67
+ case 0 :
68
+ return [ undefined ] ;
69
+ // GinChaperon [{options}] {path}
66
70
case 1 :
67
71
return [ residue [ 0 ] ] ;
68
72
default :
Original file line number Diff line number Diff line change 8
8
validateOpts ,
9
9
} from "jsr:@denops/std@^7.0.0/argument" ;
10
10
import { fillCmdArgs , normCmdArgs , parseSilent } from "../../util/cmd.ts" ;
11
+ import { ensurePath } from "../../util/ensure_path.ts" ;
11
12
import { exec } from "./command.ts" ;
12
13
13
14
export function main ( denops : Denops ) : void {
@@ -46,8 +47,8 @@ async function command(
46
47
...builtinOpts ,
47
48
] ) ;
48
49
49
- const [ abspath ] = parseResidue ( residue ) ;
50
- await exec ( denops , abspath , {
50
+ const [ rawpath ] = parseResidue ( residue ) ;
51
+ await exec ( denops , await ensurePath ( denops , rawpath ) , {
51
52
worktree : opts . worktree ,
52
53
noHead : "no-head" in opts ,
53
54
noWorktree : "no-worktree" in opts ,
@@ -60,9 +61,12 @@ async function command(
60
61
61
62
function parseResidue (
62
63
residue : string [ ] ,
63
- ) : [ string ] {
64
- // GinPatch [{options}] {path}
64
+ ) : [ string | undefined ] {
65
65
switch ( residue . length ) {
66
+ // GinPatch [{options}]
67
+ case 0 :
68
+ return [ undefined ] ;
69
+ // GinPatch [{options}] {path}
66
70
case 1 :
67
71
return [ residue [ 0 ] ] ;
68
72
default :
Original file line number Diff line number Diff line change
1
+ import type { Denops } from "jsr:@denops/std@^7.0.0" ;
2
+ import * as fn from "jsr:@denops/std@^7.0.0/function" ;
3
+
4
+ /**
5
+ * Ensure the path is absolute.
6
+ *
7
+ * It returns the absolute path of the given path. If the path is not given, it
8
+ * returns the absolute path of the current buffer.
9
+ *
10
+ * @param denops Denops instance.
11
+ * @param path Path to ensure.
12
+ * @returns Absolute path.
13
+ */
14
+ export async function ensurePath (
15
+ denops : Denops ,
16
+ path ?: string ,
17
+ ) : Promise < string > {
18
+ const bufname = await fn . expand ( denops , path ?? "%" ) as string ;
19
+ const abspath = await fn . fnamemodify ( denops , bufname , ":p" ) ;
20
+ return abspath ;
21
+ }
Original file line number Diff line number Diff line change @@ -217,9 +217,10 @@ COMMANDS *gin-commands*
217
217
directory. Commands call | cd | , | lcd | , and | tcd | respectively.
218
218
219
219
*:GinChaperon*
220
- :GinChaperon[!] [++{option} ...] {path}
220
+ :GinChaperon[!] [++{option} ...] [ {path} ]
221
221
Open three main buffers (THEIRS, WORKTREE, and OURS) and three
222
- supplemental buffers to solve conflicts on {path} .
222
+ supplemental buffers to solve conflicts on {path} . If no {path} is
223
+ specified, the default value is the current buffer.
223
224
224
225
The following options are valid as {++option} :
225
226
@@ -343,9 +344,10 @@ COMMANDS *gin-commands*
343
344
Use a bang (!) to forcibly open a buffer.
344
345
345
346
*:GinPatch*
346
- :GinPatch[!] [{++option} ...] {path}
347
+ :GinPatch[!] [{++option} ...] [ {path} ]
347
348
Open three buffers (HEAD, INDEX, and WORKTREE) to patch changes of
348
- {path} .
349
+ {path} . If no {path} is specified, the default value is the current
350
+ buffer.
349
351
350
352
The following options are valid as {++option} :
351
353
You can’t perform that action at this time.
0 commit comments