aboutsummaryrefslogtreecommitdiff
path: root/src/nix/edit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/edit.cc')
-rw-r--r--src/nix/edit.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nix/edit.cc b/src/nix/edit.cc
index fc48db0d7..76a134b1f 100644
--- a/src/nix/edit.cc
+++ b/src/nix/edit.cc
@@ -28,19 +28,19 @@ struct CmdEdit : InstallableCommand
{
auto state = getEvalState();
- auto [v, pos] = installable->toValue(*state);
+ const auto [file, line] = [&] {
+ auto [v, pos] = installable->toValue(*state);
- try {
- pos = findPackageFilename(*state, *v, installable->what());
- } catch (NoPositionInfo &) {
- }
-
- if (pos == noPos)
- throw Error("cannot find position information for '%s", installable->what());
+ try {
+ return findPackageFilename(*state, *v, installable->what());
+ } catch (NoPositionInfo &) {
+ throw Error("cannot find position information for '%s", installable->what());
+ }
+ }();
stopProgressBar();
- auto args = editorFor(pos);
+ auto args = editorFor(file, line);
restoreProcessContext();