diff options
| -rw-r--r-- | core/Messages.zig | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 9ba1bc93..4dd39097 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -558,12 +558,17 @@ pub fn act(p: *Pardes, id: usize) void { } if (lead.kind != .@"error" or lead.places_len == 0 or id >= MAX_PANES) return history(p, id); const pane = p.panes[id] orelse return; + const picked = pardes.Pick.asked(p); var rows: std.Io.Writer.Allocating = .init(p.gpa); errdefer rows.deinit(); - for (lead.places[0..lead.places_len]) |*place| rows.writer.print("{s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() }) catch |err| return reportError(p, .at(id), "Message", err); + // A row as its list reads its column: a picker's as the compiler wrote + // it, `path:line:col: words` (Prompt's rows too: a column with a blank + // after it is the line's text to look.parsePathLine), a +Search's as + // its locations are, `path:line:col words` (locations.parse). + for (lead.places[0..lead.places_len]) |*place| rows.writer.print("{s}:{d}:{d}{s} {s}\n", .{ place.path.slice(), place.line, place.col, if (picked) ":" else "", place.text.slice() }) catch |err| return reportError(p, .at(id), "Message", err); const cause = lead.src; const content = rows.toOwnedSlice() catch |err| return reportError(p, .at(id), "Message", err); - if (pardes.Pick.asked(p)) { + if (picked) { defer p.gpa.free(content); // The cause cut at a character's start to the word's room. const src = cause.slice(); @@ -1875,3 +1880,27 @@ test "SPC e keeps the error it walks: the file it lands in, not open when the er } else return error.LineNotShown; try std.testing.expect(std.mem.indexOf(u8, marked, "var s = 1; \u{2717} local variable is never mutated") != null); } + +test "SPC e lands on its place's column, where jumps walk and where they open a pane" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); + defer p.deinit(); + const pane = try p.setTestFile("one\ntwo\n var s = 1;\nfour\n"); + for ([_]config.Settings.Jumps{ .walk, .@"new-pane" }) |jumps| { + p.settings.jumps = jumps; + p.view().active = p.paneBySerial(pane.serial).?; + pane.body.cur_row = 0; + pane.body.cur_col = 0; + p.messages.live_len = 0; + const err = keep(p, .@"error", 0, "@p9 zig build", "exit 2"); + err.places[0] = .{ .line = 3, .col = 9 }; + err.places[0].path.set("/test.txt"); + err.places[0].text.set("local variable is never mutated"); + err.places_len = 1; + for (" e") |c| p.update(.{ .key = .{ .cp = c } }); + while (p.nextEffect()) |_| {} + const landed = p.panes[p.view().active].?; + try std.testing.expectEqualStrings("/test.txt", landed.file.?.path); + try std.testing.expectEqual(@as(i32, 2), landed.body.cur_row); + try std.testing.expectEqual(@as(i32, 8), landed.body.cur_col); + } +} |
