Skip to content

Commit

Permalink
fix(tree): make rootNodeWithOffset non-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Dec 12, 2024
1 parent c70aec4 commit 8dc00a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test "Tree" {
defer tree.destroy();
try testing.expectEqual(language, tree.language());
try testing.expectEqual(13, tree.rootNode().endByte());
try testing.expectEqual(3, tree.rootNodeWithOffset(3, .{ .row = 0, .column = 3 }).?.startByte());
try testing.expectEqual(3, tree.rootNodeWithOffset(3, .{ .row = 0, .column = 3 }).startByte());

var ranges = tree.getIncludedRanges();
var range: ts.Range = .{
Expand Down
5 changes: 2 additions & 3 deletions src/tree.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ pub const Tree = opaque {

/// Get the root node of the syntax tree, with
/// its position shifted forward by the given offset.
pub inline fn rootNodeWithOffset(self: *const Tree, offset_bytes: u32, offset_extent: Point) ?Node {
const node = ts_tree_root_node_with_offset(self, offset_bytes, offset_extent);
return if (!ts_node_is_null(node)) node else null;
pub inline fn rootNodeWithOffset(self: *const Tree, offset_bytes: u32, offset_extent: Point) Node {
return ts_tree_root_node_with_offset(self, offset_bytes, offset_extent);
}

/// Get the language that was used to parse the syntax tree.
Expand Down

0 comments on commit 8dc00a0

Please sign in to comment.