refactor: improve const correctness in AST navigation functions
This commit is contained in:
parent
30af629a1a
commit
8100e7d52b
1 changed files with 6 additions and 7 deletions
|
@ -4298,7 +4298,7 @@ pub const Editor = struct {
|
||||||
}
|
}
|
||||||
pub const selections_reverse_meta: Meta = .{ .description = "Reverse selection" };
|
pub const selections_reverse_meta: Meta = .{ .description = "Reverse selection" };
|
||||||
|
|
||||||
fn node_at_selection(self: *Self, sel: Selection, root: Buffer.Root, metrics: Buffer.Metrics) error{Stop}!syntax.Node {
|
fn node_at_selection(self: *const Self, sel: Selection, root: Buffer.Root, metrics: Buffer.Metrics) error{Stop}!syntax.Node {
|
||||||
const syn = self.syntax orelse return error.Stop;
|
const syn = self.syntax orelse return error.Stop;
|
||||||
const node = try syn.node_at_point_range(.{
|
const node = try syn.node_at_point_range(.{
|
||||||
.start_point = .{
|
.start_point = .{
|
||||||
|
@ -4316,7 +4316,7 @@ pub const Editor = struct {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn top_node_at_selection(self: *Self, sel: Selection, root: Buffer.Root, metrics: Buffer.Metrics) error{Stop}!syntax.Node {
|
fn top_node_at_selection(self: *const Self, sel: Selection, root: Buffer.Root, metrics: Buffer.Metrics) error{Stop}!syntax.Node {
|
||||||
var node = try self.node_at_selection(sel, root, metrics);
|
var node = try self.node_at_selection(sel, root, metrics);
|
||||||
if (node.isNull()) return node;
|
if (node.isNull()) return node;
|
||||||
var parent = node.getParent();
|
var parent = node.getParent();
|
||||||
|
@ -4331,10 +4331,9 @@ pub const Editor = struct {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_top_node_at_cursor(self: *Self, root: Buffer.Root, cursel: *CurSel, metrics: Buffer.Metrics) !void {
|
fn top_node_at_cursel(self: *const Self, cursel: *const CurSel, root: Buffer.Root, metrics: Buffer.Metrics) error{Stop}!syntax.Node {
|
||||||
cursel.disable_selection(root, self.metrics);
|
const sel = try cursel.to_selection(root, metrics);
|
||||||
const sel = (try cursel.enable_selection(root, self.metrics)).*;
|
return try self.top_node_at_selection(sel, root, metrics);
|
||||||
return cursel.select_node(try self.top_node_at_selection(sel, root, metrics), root, metrics);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expand_selection_to_parent_node(self: *Self, root: Buffer.Root, cursel: *CurSel, metrics: Buffer.Metrics) !void {
|
fn expand_selection_to_parent_node(self: *Self, root: Buffer.Root, cursel: *CurSel, metrics: Buffer.Metrics) !void {
|
||||||
|
@ -4356,7 +4355,7 @@ pub const Editor = struct {
|
||||||
try if (cursel.selection) |_|
|
try if (cursel.selection) |_|
|
||||||
self.expand_selection_to_parent_node(root, cursel, self.metrics)
|
self.expand_selection_to_parent_node(root, cursel, self.metrics)
|
||||||
else
|
else
|
||||||
self.select_top_node_at_cursor(root, cursel, self.metrics);
|
cursel.select_node(try self.top_node_at_cursel(cursel, root, self.metrics), root, self.metrics);
|
||||||
self.clamp();
|
self.clamp();
|
||||||
try self.send_editor_jump_destination();
|
try self.send_editor_jump_destination();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue