Quellcode durchsuchen

Shell: Treat builtin names as programs and suggest them

AnotherTest vor 5 Jahren
Ursprung
Commit
1469d20e63
2 geänderte Dateien mit 12 neuen und 0 gelöschten Zeilen
  1. 4 0
      Shell/Shell.cpp
  2. 8 0
      Shell/Shell.h

+ 4 - 0
Shell/Shell.cpp

@@ -1373,6 +1373,10 @@ void Shell::cache_path()
         }
     }
 
+    // add shell builtins to the cache
+    for (const auto& builtin_name : builtin_names)
+        cached_path.append(escape_token(builtin_name));
+
     quick_sort(cached_path);
 }
 

+ 8 - 0
Shell/Shell.h

@@ -174,6 +174,14 @@ private:
 
 #undef __ENUMERATE_SHELL_BUILTIN
 
+    constexpr static const char* builtin_names[] = {
+#define __ENUMERATE_SHELL_BUILTIN(builtin) #builtin,
+
+        ENUMERATE_SHELL_BUILTINS()
+
+#undef __ENUMERATE_SHELL_BUILTIN
+    };
+
     ExitCodeOrContinuationRequest::ContinuationRequest m_should_continue { ExitCodeOrContinuationRequest::Nothing };
     StringBuilder m_complete_line_builder;
     bool m_should_break_current_command { false };