Skip to content

Commit c123789

Browse files
committed
feat: load buffer before previewing
1 parent 7e916bd commit c123789

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

builtin/previewer/buffer.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@ type Detail = {
2020
*/
2121
export function buffer(): Previewer<Detail> {
2222
return definePreviewer(async (denops, { item }, { signal }) => {
23+
// Ensure that the buffer is loaded
24+
await fn.bufload(denops, item.detail.bufnr);
25+
2326
// Retrieve buffer properties in a batch
24-
const [bufloaded, bufname, content] = await collect(denops, (denops) => [
25-
fn.bufloaded(denops, item.detail.bufnr),
27+
const [bufname, content] = await collect(denops, (denops) => [
2628
fn.bufname(denops, item.detail.bufnr),
2729
fn.getbufline(denops, item.detail.bufnr, 1, "$"),
2830
]);
2931
signal?.throwIfAborted();
3032

31-
// If buffer is not loaded, return nothing
32-
if (!bufloaded) {
33-
return;
34-
}
35-
3633
// Extract line and column details for highlighting in the preview
3734
const { line, column } = item.detail;
3835
return {

0 commit comments

Comments
 (0)