mirror of
https://github.com/NixOS/nix.git
synced 2025-11-29 05:31:00 +01:00
Make 'nix edit' etc. work again
This commit is contained in:
parent
1790698a74
commit
bb4d35dcca
15 changed files with 108 additions and 82 deletions
|
|
@ -207,8 +207,11 @@ void StorePathCommand::run(ref<Store> store, std::vector<StorePath> && storePath
|
|||
run(store, *storePaths.begin());
|
||||
}
|
||||
|
||||
Strings editorFor(const Path & file, uint32_t line)
|
||||
Strings editorFor(const SourcePath & file, uint32_t line)
|
||||
{
|
||||
auto path = file.getPhysicalPath();
|
||||
if (!path)
|
||||
throw Error("cannot open '%s' in an editor because it has no physical path", file);
|
||||
auto editor = getEnv("EDITOR").value_or("cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (line > 0 && (
|
||||
|
|
@ -217,7 +220,7 @@ Strings editorFor(const Path & file, uint32_t line)
|
|||
editor.find("vim") != std::string::npos ||
|
||||
editor.find("kak") != std::string::npos))
|
||||
args.push_back(fmt("+%d", line));
|
||||
args.push_back(file);
|
||||
args.push_back(path->abs());
|
||||
return args;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue