mirror of
https://github.com/RGBCube/serenity
synced 2025-07-06 22:27:36 +00:00
HackStudio: Append a / when completing a directory
This commit is contained in:
parent
8b3a2cdad9
commit
0be3f5b4ae
1 changed files with 11 additions and 5 deletions
|
@ -682,17 +682,23 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a
|
|||
Core::DirIterator it(full_dir, Core::DirIterator::Flags::SkipDots);
|
||||
Vector<GUI::AutocompleteProvider::Entry> options;
|
||||
|
||||
while (it.has_next()) {
|
||||
auto path = it.next_path();
|
||||
if (!(path.ends_with(".h") || Core::File::is_directory(LexicalPath::join(full_dir, path).string())))
|
||||
continue;
|
||||
if (path.starts_with(partial_basename)) {
|
||||
// FIXME: Place the cursor after the trailing > or ", even if it was
|
||||
// already typed.
|
||||
auto prefix = include_type == System ? "<" : "\"";
|
||||
auto suffix = include_type == System ? ">" : "\"";
|
||||
while (it.has_next()) {
|
||||
auto path = it.next_path();
|
||||
|
||||
if (!path.starts_with(partial_basename))
|
||||
continue;
|
||||
|
||||
if (Core::File::is_directory(LexicalPath::join(full_dir, path).string())) {
|
||||
// FIXME: Don't dismiss the autocomplete when filling these suggestions.
|
||||
auto completion = String::formatted("{}{}{}/", prefix, include_dir, path);
|
||||
options.empend(completion, include_dir.length() + partial_basename.length() + 1, GUI::AutocompleteProvider::Language::Cpp, path);
|
||||
} else if (path.ends_with(".h")) {
|
||||
// FIXME: Place the cursor after the trailing > or ", even if it was
|
||||
// already typed.
|
||||
auto completion = String::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix);
|
||||
options.append({ completion, include_dir.length() + partial_basename.length() + 1, GUI::AutocompleteProvider::Language::Cpp, path });
|
||||
options.empend(completion, include_dir.length() + partial_basename.length() + 1, GUI::AutocompleteProvider::Language::Cpp, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue