Skip to content

Commit 64270d0

Browse files
committed
Add getStartPositionFromASTNode helper function
1 parent 74f819b commit 64270d0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/helpers.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ export const getRangeFromASTNode = (
2626
);
2727
};
2828

29+
export const getStartPositionFromASTNode = (
30+
node:
31+
| parse.PropertyNode
32+
| parse.LiteralNode
33+
| parse.ObjectNode
34+
| parse.ValueNode
35+
) => {
36+
const startLine = node?.loc?.start.line || 0;
37+
const startColumn = node?.loc?.start.column || 0;
38+
39+
return new vscode.Position(startLine - 1, startColumn);
40+
};
41+
2942
export const isConfigFile = (document: vscode.TextDocument) => {
3043
let isConfigFile = false;
3144

0 commit comments

Comments
 (0)