mirror of
https://github.com/NixOS/nix
synced 2025-06-27 00:11:17 +02:00
editorFor: take a pos object instead
This commit is contained in:
parent
ec448f8bb6
commit
3774fe55fd
4 changed files with 12 additions and 16 deletions
|
@ -178,16 +178,16 @@ Strings argvToStrings(int argc, char * * argv)
|
|||
return args;
|
||||
}
|
||||
|
||||
Strings editorFor(std::string filename, int lineno)
|
||||
Strings editorFor(Pos pos)
|
||||
{
|
||||
auto editor = getEnv("EDITOR", "cat");
|
||||
auto args = tokenizeString<Strings>(editor);
|
||||
if (lineno > 0 && (
|
||||
if (pos.line > 0 && (
|
||||
editor.find("emacs") != std::string::npos ||
|
||||
editor.find("nano") != std::string::npos ||
|
||||
editor.find("vim") != std::string::npos))
|
||||
args.push_back(fmt("+%d", lineno));
|
||||
args.push_back(filename);
|
||||
args.push_back(fmt("+%d", pos.line));
|
||||
args.push_back(pos.file);
|
||||
return args;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "util.hh"
|
||||
#include "nixexpr.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -191,7 +192,7 @@ public:
|
|||
Strings argvToStrings(int argc, char * * argv);
|
||||
|
||||
/* Helper function to generate args that invoke $EDITOR on filename:lineno */
|
||||
Strings editorFor(std::string filename, int lineno);
|
||||
Strings editorFor(Pos pos);
|
||||
|
||||
/* Helper function for rendering argument labels. */
|
||||
std::string renderLabels(const Strings & labels);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue