Skip to main content
Module

x/ddc_vim/deps.ts>fn.charidx

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.charidx
import { fn } from "https://deno.land/x/ddc_vim@v2.3.0/deps.ts";
const { charidx } = fn;

Return the character index of the byte at {idx} in {string}. The index of the first character is zero. If there are no multibyte characters the returned value is equal to {idx}. When {countcc} is omitted or zero, then composing characters are not counted separately, their byte length is added to the preceding base character. When {countcc} is set to 1, then composing characters are counted as separate characters. Returns -1 if the arguments are invalid or if {idx} is greater than the index of the last byte in {string}. An error is given if the first argument is not a string, the second argument is not a number or when the third argument is present and is not zero or one. See |byteidx()| and |byteidxcomp()| for getting the byte index from the character index. Examples: echo charidx('áb́ć', 3) returns 1 echo charidx('áb́ć', 6, 1) returns 4 echo charidx('áb́ć', 16) returns -1 Can also be used as a |method|: GetName()->charidx(idx)

Parameters

denops: Denops
string: unknown
idx: unknown
optional
countcc: unknown

Returns

Promise<unknown>