Skip to content

Commit 71188a1

Browse files
committed
Add optional preview_path to file previewer
1 parent 88d3c5a commit 71188a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builtin/previewer/file.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const decoder = new TextDecoder("utf-8", { fatal: true });
99

1010
type Detail = {
1111
path: string;
12+
preview_path?: string;
1213
line?: number;
1314
column?: number;
1415
};
@@ -23,10 +24,12 @@ type Detail = {
2324
*/
2425
export function file(): Previewer<Detail> {
2526
return definePreviewer(async (denops, { item }, { signal }) => {
27+
const path = item.detail.preview_path ?? item.detail.path;
28+
2629
// Resolve the absolute path of the file
27-
const abspath = isAbsolute(item.detail.path)
28-
? item.detail.path
29-
: await fn.fnamemodify(denops, item.detail.path, ":p");
30+
const abspath = isAbsolute(path)
31+
? path
32+
: await fn.fnamemodify(denops, path, ":p");
3033
signal?.throwIfAborted();
3134

3235
try {

0 commit comments

Comments
 (0)