Skip to content

Commit 8e7e101

Browse files
committed
feat: update codeframes
1 parent 7d81914 commit 8e7e101

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

packages/core/src/format/codeframes.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as yamlAst from 'yaml-ast-parser';
2-
import { unescapePointer } from '../ref-utils.js';
2+
import { parsePointer } from '../ref-utils.js';
33
import { colorize, colorOptions } from '../logger.js';
44

55
import type { LineColLocationObject, Loc, LocationObject } from '../walk.js';
@@ -14,11 +14,6 @@ type YAMLNode = YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | YAM
1414
const MAX_LINE_LENGTH = 150;
1515
const MAX_CODEFRAME_LINES = 3;
1616

17-
// TODO: temporary
18-
function parsePointer(pointer: string) {
19-
return pointer.substr(2).split('/').map(unescapePointer);
20-
}
21-
2217
export function getCodeframe(location: LineColLocationObject, color: boolean) {
2318
colorOptions.enabled = color;
2419
const { start, end = { line: start.line, col: start.col + 1 }, source } = location;
@@ -181,7 +176,7 @@ function positionsToLoc(
181176
}
182177

183178
export function getAstNodeByPointer(root: YAMLNode, pointer: string, reportOnKey: boolean) {
184-
const pointerSegments = parsePointer(pointer);
179+
const [, ...pointerSegments] = parsePointer(pointer);
185180
if (root === undefined) {
186181
return undefined;
187182
}

0 commit comments

Comments
 (0)