Browse Source

Resotre inherit flag in clish_view_resolve_prefix()

Serj Kalichev 5 years ago
parent
commit
09293c1bfb
3 changed files with 7 additions and 5 deletions
  1. 2 2
      clish/nspace/nspace.c
  2. 1 1
      clish/view.h
  3. 4 2
      clish/view/view.c

+ 2 - 2
clish/nspace/nspace.c

@@ -179,7 +179,7 @@ clish_command_t *clish_nspace_resolve_prefix(clish_nspace_t *this, const char *n
 	char *real_prefix = NULL;
 
 	if (!clish_nspace__get_prefix(this))
-		return clish_view_resolve_prefix(view, name);
+		return clish_view_resolve_prefix(view, name, this->inherit);
 
 	if (!(in_line = clish_nspace_after_prefix(
 		clish_nspace__get_prefix_regex(this), name, &real_prefix)))
@@ -190,7 +190,7 @@ clish_command_t *clish_nspace_resolve_prefix(clish_nspace_t *this, const char *n
 		in_line++;
 
 	if (in_line[0] != '\0') {
-		cmd = clish_view_resolve_prefix(view, in_line);
+		cmd = clish_view_resolve_prefix(view, in_line, this->inherit);
 		if (!cmd) {
 			lub_string_free(real_prefix);
 			return NULL;

+ 1 - 1
clish/view.h

@@ -42,7 +42,7 @@ const clish_command_t *clish_view_find_next_completion(clish_view_t *instance,
 clish_command_t *clish_view_resolve_command(clish_view_t *instance,
 	const char *line);
 clish_command_t *clish_view_resolve_prefix(clish_view_t *instance,
-	const char *line);
+	const char *line, bool_t inherit);
 void clish_view_dump(clish_view_t *instance);
 void clish_view_insert_nspace(clish_view_t *instance, clish_nspace_t *nspace);
 void clish_view_clean_proxy(clish_view_t *instance);

+ 4 - 2
clish/view/view.c

@@ -126,7 +126,7 @@ static int cmd_resolve(const void *key, const void *data)
  * the first match will be the longest command.
  */
 clish_command_t *clish_view_resolve_prefix(clish_view_t *this,
-	const char *line)
+	const char *line, bool_t inherit)
 {
 	lub_list_node_t *iter;
 	clish_command_t *res = NULL;
@@ -139,6 +139,8 @@ clish_command_t *clish_view_resolve_prefix(clish_view_t *this,
 	 * in a case then the both NAMESPACEs have the
 	 * commands with the same name.
 	 */
+	if (!inherit)
+		return res;
 	for (iter = lub_list__get_tail(this->nspaces);
 		iter; iter = lub_list_node__get_prev(iter)) {
 		clish_nspace_t *nspace = (clish_nspace_t *)lub_list_node__get_data(iter);
@@ -154,7 +156,7 @@ clish_command_t *clish_view_resolve_prefix(clish_view_t *this,
 clish_command_t *clish_view_resolve_command(clish_view_t *this,
 	const char *line)
 {
-	clish_command_t *result = clish_view_resolve_prefix(this, line);
+	clish_command_t *result = clish_view_resolve_prefix(this, line, BOOL_TRUE);
 
 	if (result) {
 		clish_action_t *action = clish_command__get_action(result);