Skip to content

Commit f5a22ff

Browse files
committed
👍 Add getchangelist() to buffer-function
1 parent 7e8a304 commit f5a22ff

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

denops_std/function/_generated.ts

Lines changed: 0 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

denops_std/function/buffer.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Denops } from "https://deno.land/x/denops_core@v4.0.0/mod.ts";
2-
import type { BufInfo } from "./types.ts";
2+
import type { BufInfo, ChangeList } from "./types.ts";
33

44
/**
55
* If the **{buf}** argument is a number, buffer numbers are used.
@@ -478,6 +478,33 @@ export function getbufvar(
478478
return denops.call("getbufvar", ...args);
479479
}
480480

481+
/**
482+
* Returns the `changelist` for the buffer **{buf}**. For the use
483+
* of **{buf}**, see `bufname()` above. If buffer **{buf}** doesn't
484+
* exist, an empty list is returned.
485+
*
486+
* The returned list contains two entries: a list with the change
487+
* locations and the current position in the list. Each
488+
* entry in the change list is a dictionary with the following
489+
* entries:
490+
* col column number
491+
* coladd column offset for 'virtualedit'
492+
* lnum line number
493+
* If buffer **{buf}** is the current buffer, then the current
494+
* position refers to the position in the list. For other
495+
* buffers, it is set to the length of the list.
496+
*
497+
* Can also be used as a `method`:
498+
*
499+
* GetBufnr()->getchangelist()
500+
*/
501+
export async function getchangelist(
502+
denops: Denops,
503+
buf?: BufNameArg,
504+
): Promise<ChangeList | []> {
505+
return await denops.call("getchangelist", buf) as ChangeList;
506+
}
507+
481508
/**
482509
* Set line **{lnum}** to **{text}** in buffer **{buf}**. This works like
483510
* `setline()` for the specified buffer.

denops_std/function/types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,20 @@ export interface PlacedSign {
197197
/** Sign name. */
198198
name: string;
199199
}
200+
201+
/**
202+
* Type of `getchangelist()` result.
203+
*/
204+
export type ChangeList = [locations: ChangeListLocation[], pos: number];
205+
206+
/**
207+
* Type of `getchangelist()` result.
208+
*/
209+
export interface ChangeListLocation {
210+
/** Column number. */
211+
col: number;
212+
/** Column offset for 'virtualedit'. */
213+
coladd: number;
214+
/** Line number. */
215+
lnum: number;
216+
}

0 commit comments

Comments
 (0)