Add select object rail
This commit is contained in:
+18
@@ -33,6 +33,7 @@ const PrefixRail = enum {
|
||||
none,
|
||||
insert_space,
|
||||
match,
|
||||
select_object,
|
||||
go,
|
||||
repeat,
|
||||
delete,
|
||||
@@ -568,6 +569,7 @@ pub const Client = struct {
|
||||
.none => if (self.pending_count != 0) "count pending" else "",
|
||||
.insert_space => "insert-space: n normal Space literal text commits space+text",
|
||||
.match => "match: m jump s inside a around ( { [ quotes",
|
||||
.select_object => "select-object: w word l line i indent p param f form d diagnostic",
|
||||
.go => "go: d definition r references e diagnostic a parameter",
|
||||
.repeat => "repeat: digits count . repeat-last",
|
||||
.delete => "delete: d line h previous-char l char",
|
||||
@@ -1198,6 +1200,7 @@ pub const Client = struct {
|
||||
if (std.mem.eql(u8, text, "b")) return self.repeatSelectionProtocol("command move_word_back", self.takeRepeat());
|
||||
if (std.mem.eql(u8, text, "e")) return self.repeatSelectionProtocol("command move_word_end", self.takeRepeat());
|
||||
if (std.mem.eql(u8, text, "m")) return self.openPrefix(.match);
|
||||
if (std.mem.eql(u8, text, "o")) return self.openPrefix(.select_object);
|
||||
if (std.mem.eql(u8, text, "g")) return self.openPrefix(.go);
|
||||
if (text.len == 1) {
|
||||
if (self.objectRangeForKey(text[0])) |range| {
|
||||
@@ -1256,6 +1259,9 @@ pub const Client = struct {
|
||||
.match => self.applyMatchRail(event) catch |err| {
|
||||
self.message = @errorName(err);
|
||||
},
|
||||
.select_object => self.applySelectObjectRail(event) catch |err| {
|
||||
self.message = @errorName(err);
|
||||
},
|
||||
.go => try self.applyGoRail(event),
|
||||
.repeat => self.applyKnownRailOrMessage(event, "repeat rail ready"),
|
||||
.delete => try self.applyDeleteRail(event),
|
||||
@@ -1878,6 +1884,18 @@ pub const Client = struct {
|
||||
self.applyKnownRailOrMessage(event, "go rail ready");
|
||||
}
|
||||
|
||||
fn applySelectObjectRail(self: *Client, event: input.Event) !void {
|
||||
const text = eventText(event) orelse return self.unknownPrefixOrInput("select object");
|
||||
if (text.len == 1) {
|
||||
const range = try self.objectRangeForKey(text[0]);
|
||||
try self.session.selectRange(range.start, range.end);
|
||||
self.mode = .select;
|
||||
self.message = "selected object";
|
||||
return;
|
||||
}
|
||||
self.unknownPrefixOrInput("select object");
|
||||
}
|
||||
|
||||
const ParameterDirection = enum { next, previous };
|
||||
|
||||
fn moveParameter(self: *Client, direction: ParameterDirection) !void {
|
||||
|
||||
Reference in New Issue
Block a user