summaryrefslogtreecommitdiff
path: root/core/edit_cmd.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/edit_cmd.zig')
-rw-r--r--core/edit_cmd.zig17
1 files changed, 10 insertions, 7 deletions
diff --git a/core/edit_cmd.zig b/core/edit_cmd.zig
index ab4f2b5d..aec97c63 100644
--- a/core/edit_cmd.zig
+++ b/core/edit_cmd.zig
@@ -134,13 +134,15 @@ const World = struct {
/// What the Edit sees of a pane. Its name is a copy in `arena`: the pane
/// may be gone by the time a running Edit's end says it. Its text is the
-/// pane's own, read only while the Edit runs its commands' parse.
+/// file's (File.fileText: the `Changes` layer's lines are none of it), as
+/// 9P serves it, its dot in that text: what it changes is the file's, and
+/// what its `w` writes.
fn fileOf(arena: std.mem.Allocator, pane: *panes.Pane, id: usize) !sam.File {
const f = ninep_pane.fileOf(pane).?;
return .{
.name = try arena.dupe(u8, f.path),
- .text = f.content,
- .dot = ninep_pane.dotOf(pane),
+ .text = try panes.File.fileText(f, arena),
+ .dot = ninep_pane.fileDot(pane),
.dirty = ninep_pane.dirtyOf(pane),
.scratch = f.output != null,
.id = id,
@@ -406,17 +408,18 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void {
o.text = outputs[j];
};
if (ops.len > 0) {
- const new = sam.apply(p.gpa, pf.content, ops) catch |err| return p.reportError(.at(at), "Edit", err);
+ const was = panes.File.fileText(pf, p.scratch.allocator()) catch |err| return p.reportError(.at(at), "Edit", err);
+ const new = sam.apply(p.gpa, was, ops) catch |err| return p.reportError(.at(at), "Edit", err);
// `s/a/a/` changes nothing: no undo step, no new revision.
- if (std.mem.eql(u8, new, pf.content)) p.gpa.free(new) else {
+ if (std.mem.eql(u8, new, was)) p.gpa.free(new) else {
panes.File.pushUndo(p, pane) catch |err| {
p.gpa.free(new);
return p.reportError(.at(at), "Edit", err);
};
- panes.File.setContent(p, pf, new);
+ panes.File.load(p, pf, new);
}
}
- if (ops.len > 0 or f.moved) ninep_pane.setDot(p.settings.tab, pane, sam.moveDot(f.dot, ops));
+ if (ops.len > 0 or f.moved) ninep_pane.setFileDot(p.settings.tab, pane, sam.moveDot(f.dot, ops));
if (f.renamed) ninep_pane.nameBuffer(p, f.id, f.name, false) catch |err| p.reportError(.at(f.id), "Edit", err);
}
// What was printed, `>`'s output in its place among it.