From 3f69a650b3c3f014eda5d722aef97f801e4a5b81 Mon Sep 17 00:00:00 2001 From: tennashi Date: Sun, 30 Mar 2025 02:18:59 +0900 Subject: [PATCH] Add optional previewPath to file previewer --- builtin/previewer/file.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin/previewer/file.ts b/builtin/previewer/file.ts index f6609a2..2414397 100644 --- a/builtin/previewer/file.ts +++ b/builtin/previewer/file.ts @@ -9,6 +9,7 @@ const decoder = new TextDecoder("utf-8", { fatal: true }); type Detail = { path: string; + previewPath?: string; line?: number; column?: number; }; @@ -23,10 +24,12 @@ type Detail = { */ export function file(): Previewer { return definePreviewer(async (denops, { item }, { signal }) => { + const path = item.detail.previewPath ?? item.detail.path; + // Resolve the absolute path of the file - const abspath = isAbsolute(item.detail.path) - ? item.detail.path - : await fn.fnamemodify(denops, item.detail.path, ":p"); + const abspath = isAbsolute(path) + ? path + : await fn.fnamemodify(denops, path, ":p"); signal?.throwIfAborted(); try {