import { linePatch } from "https://deno.land/x/denops_lsputil@v0.9.4/mod.ts";
Replace the range of before
and after
the cursor with text
.
If in cmdline mode, edit cmdline. Otherwise, edit the buffer.
0-based and columns are utf-16 offset.
NOTE: In cmdline mode, do not include line breaks in text
.
import { Denops } from "https://deno.land/x/denops_std@v5.0.1/mod.ts";
import { LineContext } from "./context.ts"
import { linePatch } from "./patch.ts"
export async function main(denops: Denops): Promise<void> {
const ctx = await LineContext.create(denops);
// String before the cursor
const beforeLine = ctx.text.slice(0, ctx.character);
// Replace string before the cursor with 'foo'
await linePatch(denops, beforeLine.length, 0, "foo");
}