MCPcopy Create free account
hub / github.com/Wscats/vscode-explore / getPrevCodePoint

Function getPrevCodePoint

contributes/src/vs/base/common/strings.ts:491–500  ·  view source on GitHub ↗

* get the code point that ends right before offset `offset`

(str: string, offset: number)

Source from the content-addressed store, hash-verified

489 * get the code point that ends right before offset `offset`
490 */
491function getPrevCodePoint(str: string, offset: number): number {
492 const charCode = str.charCodeAt(offset - 1);
493 if (isLowSurrogate(charCode) && offset > 1) {
494 const prevCharCode = str.charCodeAt(offset - 2);
495 if (isHighSurrogate(prevCharCode)) {
496 return computeCodePoint(prevCharCode, charCode);
497 }
498 }
499 return charCode;
500}
501
502export function nextCharLength(str: string, offset: number): number {
503 const graphemeBreakTree = GraphemeBreakTree.getInstance();

Callers 2

prevCharLengthFunction · 0.85
_getCharContainingOffsetFunction · 0.85

Calls 3

isLowSurrogateFunction · 0.85
isHighSurrogateFunction · 0.85
computeCodePointFunction · 0.85

Tested by

no test coverage detected