mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 08:56:10 +08:00
Some doc omissions in complete.cpp
And undo a couple unrelated changes that came along.
This commit is contained in:
parent
9daffc7080
commit
9b5625a66b
@ -2379,6 +2379,7 @@ static int builtin_exit(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||
static int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
env_var_t dir_in;
|
||||
wcstring dir;
|
||||
int res = STATUS_BUILTIN_OK;
|
||||
|
||||
if (argv[1] == NULL) {
|
||||
dir_in = env_get_string(L"HOME");
|
||||
@ -2414,16 +2415,15 @@ static int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
streams.err.append(parser.current_line());
|
||||
}
|
||||
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
if (wchdir(dir) != 0) {
|
||||
res = 1;
|
||||
} else if (wchdir(dir) != 0) {
|
||||
struct stat buffer;
|
||||
int status;
|
||||
|
||||
status = wstat(dir, &buffer);
|
||||
if (!status && S_ISDIR(buffer.st_mode)) {
|
||||
streams.err.append_format(_(L"%ls: Permission denied: '%ls'\n"), argv[0], dir.c_str());
|
||||
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: '%ls' is not a directory\n"), argv[0], dir.c_str());
|
||||
}
|
||||
@ -2432,14 +2432,13 @@ static int builtin_cd(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
streams.err.append(parser.current_line());
|
||||
}
|
||||
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
res = 1;
|
||||
} else if (!env_set_pwd()) {
|
||||
res = 1;
|
||||
streams.err.append_format(_(L"%ls: Could not set PWD variable\n"), argv[0]);
|
||||
}
|
||||
|
||||
if (!env_set_pwd()) {
|
||||
streams.err.append_format(_(L"%ls: Could not set PWD variable\n"), argv[0]);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
} else
|
||||
return STATUS_BUILTIN_OK;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Implementation of the builtin count command, used to count the number of arguments sent to it.
|
||||
@ -3121,7 +3120,7 @@ static const builtin_data_t builtin_datas[] = {
|
||||
{L"[", &builtin_test, N_(L"Test a condition")},
|
||||
#if 0
|
||||
// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
|
||||
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
|
||||
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
|
||||
#endif
|
||||
{L"and", &builtin_generic, N_(L"Execute command if previous command suceeded")},
|
||||
{L"begin", &builtin_generic, N_(L"Create a block of code")},
|
||||
|
@ -123,7 +123,7 @@ typedef struct complete_entry_opt {
|
||||
}
|
||||
|
||||
} complete_entry_opt_t;
|
||||
// Last value used in the order field of completion_entry_t.
|
||||
/// Last value used in the order field of completion_entry_t.
|
||||
static unsigned int kCompleteOrder = 0;
|
||||
|
||||
/// Struct describing a command completion.
|
||||
@ -169,7 +169,7 @@ struct completion_entry_set_comparer {
|
||||
typedef std::set<completion_entry_t, completion_entry_set_comparer> completion_entry_set_t;
|
||||
static completion_entry_set_t completion_set;
|
||||
|
||||
// Comparison function to sort completions by their order field.
|
||||
/// Comparison function to sort completions by their order field.
|
||||
static bool compare_completions_by_order(const completion_entry_t *p1,
|
||||
const completion_entry_t *p2) {
|
||||
return p1->order < p2->order;
|
||||
@ -202,7 +202,7 @@ static complete_flags_t resolve_auto_space(const wcstring &comp, complete_flags_
|
||||
return new_flags;
|
||||
}
|
||||
|
||||
// completion_t functions. Note that the constructor resolves flags!
|
||||
/// completion_t functions. Note that the constructor resolves flags!
|
||||
completion_t::completion_t(const wcstring &comp, const wcstring &desc, string_fuzzy_match_t mat,
|
||||
complete_flags_t flags_val)
|
||||
: completion(comp), description(desc), match(mat), flags(resolve_auto_space(comp, flags_val)) {}
|
||||
@ -374,6 +374,7 @@ void append_completion(std::vector<completion_t> *completions, const wcstring &c
|
||||
// Nasty hack for #1241 - since the constructor needs the completion string to resolve
|
||||
// AUTO_SPACE, and we aren't providing it with the completion, we have to do the resolution
|
||||
// ourselves. We should get this resolving out of the constructor.
|
||||
assert(completions != NULL);
|
||||
const wcstring empty;
|
||||
completions->push_back(completion_t(empty, empty, match, resolve_auto_space(comp, flags)));
|
||||
completion_t *last = &completions->back();
|
||||
@ -515,21 +516,31 @@ static void parse_cmd_string(const wcstring &str, wcstring &path, wcstring &cmd)
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy any strings in possible_comp which have the specified prefix to the completer's completion
|
||||
/// array. The prefix may contain wildcards. The output will consist of completion_t structs.
|
||||
/// Copy any strings in possible_comp which have the specified prefix to the
|
||||
/// completer's completion array. The prefix may contain wildcards. The output
|
||||
/// will consist of completion_t structs.
|
||||
///
|
||||
/// There are three ways to specify descriptions for each completion. Firstly, if a description has
|
||||
/// already been added to the completion, it is _not_ replaced. Secondly, if the desc_func function
|
||||
/// is specified, use it to determine a dynamic completion. Thirdly, if none of the above are
|
||||
/// available, the desc string is used as a description.
|
||||
/// There are three ways to specify descriptions for each completion. Firstly,
|
||||
/// if a description has already been added to the completion, it is _not_
|
||||
/// replaced. Secondly, if the desc_func function is specified, use it to
|
||||
/// determine a dynamic completion. Thirdly, if none of the above are available,
|
||||
/// the desc string is used as a description.
|
||||
///
|
||||
/// \param wc_escaped the prefix, possibly containing wildcards. The wildcard should not have been
|
||||
/// unescaped, i.e. '*' should be used for any string, not the ANY_STRING character.
|
||||
/// \param desc the default description, used for completions with no embedded description. The
|
||||
/// description _may_ contain a COMPLETE_SEP character, if not, one will be prefixed to it
|
||||
/// \param desc_func the function that generates a description for those completions witout an
|
||||
/// embedded description
|
||||
/// \param possible_comp the list of possible completions to iterate over
|
||||
/// @param wc_escaped
|
||||
/// the prefix, possibly containing wildcards. The wildcard should not have
|
||||
/// been unescaped, i.e. '*' should be used for any string, not the
|
||||
/// ANY_STRING character.
|
||||
/// @param desc
|
||||
/// the default description, used for completions with no embedded
|
||||
/// description. The description _may_ contain a COMPLETE_SEP character, if
|
||||
/// not, one will be prefixed to it
|
||||
/// @param desc_func
|
||||
/// the function that generates a description for those completions witout an
|
||||
/// embedded description
|
||||
/// @param possible_comp
|
||||
/// the list of possible completions to iterate over
|
||||
/// @param flags
|
||||
/// The flags
|
||||
void completer_t::complete_strings(const wcstring &wc_escaped, const wchar_t *desc,
|
||||
wcstring (*desc_func)(const wcstring &),
|
||||
std::vector<completion_t> &possible_comp,
|
||||
@ -829,6 +840,7 @@ static void complete_load(const wcstring &name, bool reload) {
|
||||
|
||||
/// Performed on main thread, from background thread. Return type is ignored.
|
||||
static int complete_load_no_reload(wcstring *name) {
|
||||
assert(name != NULL);
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
complete_load(*name, false);
|
||||
return 0;
|
||||
@ -1540,7 +1552,7 @@ wcstring complete_print() {
|
||||
return out;
|
||||
}
|
||||
|
||||
// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list.
|
||||
/// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list.
|
||||
static pthread_mutex_t wrapper_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
typedef std::map<wcstring, wcstring_list_t> wrapper_map_t;
|
||||
static wrapper_map_t &wrap_map() {
|
||||
@ -1554,7 +1566,8 @@ static wrapper_map_t &wrap_map() {
|
||||
return *wrapper_map;
|
||||
}
|
||||
|
||||
// Add a new target that is wrapped by command. Example: __fish_sgrep (command) wraps grep (target).
|
||||
/// Add a new target that is wrapped by command. Example: __fish_sgrep (command) wraps grep
|
||||
/// (target).
|
||||
bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) {
|
||||
if (command.empty() || new_target.empty()) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user