Commit Diff


commit - e6924fe055d8c4646b5acf2f7eaab77808d5cc27
commit + 76ebdf31b4f697c5f276b1e8d23c153f21de0a1b
blob - ae284dfd353c14f6b2259cce4de3298ef58bdfcf
blob + 2fb827c32a8f8352dc71ebb24a5761047f91dc84
--- README.md
+++ README.md
@@ -70,4 +70,12 @@ magdalena select
 
 # Fuzzy pick from any piped list
 git ls-files | ./zig-out/bin/magdalena select
+
+# Embed the picker in an editor: write the pick to a file, do not open
+./zig-out/bin/magdalena --choose-file /tmp/pick look-file
 ```
+
+With `--choose-file`, any picker command writes the selection to the given
+file and exits instead of opening an editor. File pickers write the path and
+grep writes `file:line`. History logging is skipped because the embedding
+editor owns the open event.
blob - 01ca487d12d989efbfa1dc77f50065c18f0d9e8f
blob + 1cbf6afd6fe5f49b7d14aaa9c4665e8e72eccc7b
--- src/navigate.zig
+++ src/navigate.zig
@@ -552,12 +552,16 @@ pub fn gitStatus(
         }
     }
     const file = target orelse return error.UserAbort;
-    try std.Io.Dir.accessAbsolute(input_output.runtime(), file, .{
+    std.Io.Dir.cwd().access(input_output.runtime(), file, .{
         .follow_symlinks = true,
         .read = false,
         .write = false,
         .execute = false,
-    });
+    }) catch |err| {
+        input_output.warn("Selected file no longer exists or is inaccessible:" ++
+            " {s} ({})\n", .{ file, err });
+        return error.UserAbort;
+    };
     try gotoFile(history, file, null, app_config, choose_file);
 }
 
blob - 2bab06cf37cf060ccb8e1889d7f36c7720b56be6
blob + 62b925916033a27e96e57a2e281b10469721fdf7
--- src/picker.zig
+++ src/picker.zig
@@ -977,6 +977,7 @@ pub fn buildUgrepArgv(
         "--smart-case",
         "--ignore-binary",
         "--color=never",
+        "-Z1",
     });
     for (ignored_patterns) |pattern| {
         assert(pattern.len > 0);
@@ -1004,7 +1005,7 @@ pub fn buildUgrepArgv(
         try argv.append(allocator, "--");
         try argv.append(allocator, query);
     }
-    assert(argv.items.len >= 9);
+    assert(argv.items.len >= 10);
     return argv;
 }
 
@@ -1777,6 +1778,7 @@ test "buildUgrepArgv: exact sequence without shell quo
         "--smart-case",
         "--ignore-binary",
         "--color=never",
+        "-Z1",
         "--exclude-dir",
         "node_modules",
         "--exclude",