parent
e784db4ad6
commit
2435949fae
|
@ -582,6 +582,11 @@ Completions CommandManager::complete(const Context& context,
|
||||||
return offset_pos(shell_complete(context, flags, tokens[tok_idx].content(),
|
return offset_pos(shell_complete(context, flags, tokens[tok_idx].content(),
|
||||||
cursor_pos_in_token), start);
|
cursor_pos_in_token), start);
|
||||||
|
|
||||||
|
case Token::Type::ValExpand:
|
||||||
|
return {start , cursor_pos,
|
||||||
|
ShellManager::instance().complete_env_var(
|
||||||
|
tokens[tok_idx].content(), cursor_pos_in_token) };
|
||||||
|
|
||||||
case Token::Type::Raw:
|
case Token::Type::Raw:
|
||||||
case Token::Type::RawQuoted:
|
case Token::Type::RawQuoted:
|
||||||
case Token::Type::RawEval:
|
case Token::Type::RawEval:
|
||||||
|
|
|
@ -234,4 +234,12 @@ String ShellManager::get_val(StringView name, const Context& context) const
|
||||||
return env_var->func(name, context);
|
return env_var->func(name, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CandidateList ShellManager::complete_env_var(StringView prefix,
|
||||||
|
ByteCount cursor_pos) const
|
||||||
|
{
|
||||||
|
return complete(prefix, cursor_pos, m_env_vars |
|
||||||
|
transform([](const EnvVarDesc& desc) -> const String&
|
||||||
|
{ return desc.str; }));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "flags.hh"
|
#include "flags.hh"
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
#include "completion.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,8 @@ public:
|
||||||
void register_env_var(StringView str, bool prefix, EnvVarRetriever retriever);
|
void register_env_var(StringView str, bool prefix, EnvVarRetriever retriever);
|
||||||
String get_val(StringView name, const Context& context) const;
|
String get_val(StringView name, const Context& context) const;
|
||||||
|
|
||||||
|
CandidateList complete_env_var(StringView prefix, ByteCount cursor_pos) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
|
struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; };
|
||||||
Vector<EnvVarDesc> m_env_vars;
|
Vector<EnvVarDesc> m_env_vars;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user