mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:32:45 +00:00 
			
		
		
		
	HackStudio+LibGUI: Handle #include quotes and brackets in the engine
Previously we had a special case in order to auto-append quotes or angle brackets to #include statements. After the previous commit this is no longer necessary.
This commit is contained in:
		
							parent
							
								
									a5b3c3f85f
								
							
						
					
					
						commit
						f699dbdc3f
					
				
					 2 changed files with 4 additions and 13 deletions
				
			
		|  | @ -670,7 +670,8 @@ Optional<Vector<GUI::AutocompleteProvider::Entry>> CppComprehensionEngine::try_a | |||
|         if (!(path.ends_with(".h") || Core::File::is_directory(LexicalPath::join(full_dir, path).string()))) | ||||
|             continue; | ||||
|         if (path.starts_with(partial_basename)) { | ||||
|             options.append({ path, partial_basename.length(), include_type, GUI::AutocompleteProvider::Language::Cpp }); | ||||
|             auto completion = include_type == GUI::AutocompleteProvider::CompletionKind::ProjectInclude ? String::formatted("<{}>", path) : String::formatted("\"{}\"", path); | ||||
|             options.append({ completion, partial_basename.length() + 1, include_type, GUI::AutocompleteProvider::Language::Cpp, path }); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -181,10 +181,10 @@ void AutocompleteBox::apply_suggestion() | |||
|         return; | ||||
| 
 | ||||
|     auto suggestion_index = m_suggestion_view->model()->index(selected_index.row()); | ||||
|     auto suggestion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_string(); | ||||
|     auto completion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_string(); | ||||
|     size_t partial_length = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::PartialInputLength).to_i64(); | ||||
| 
 | ||||
|     VERIFY(suggestion.length() >= partial_length); | ||||
|     VERIFY(completion.length() >= partial_length); | ||||
|     if (!m_editor->has_selection()) { | ||||
|         auto cursor = m_editor->cursor(); | ||||
|         VERIFY(m_editor->cursor().column() >= partial_length); | ||||
|  | @ -194,16 +194,6 @@ void AutocompleteBox::apply_suggestion() | |||
|         m_editor->delete_text_range(TextRange(start, end)); | ||||
|     } | ||||
| 
 | ||||
|     auto completion_kind = (GUI::AutocompleteProvider::CompletionKind)suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Kind).as_u32(); | ||||
| 
 | ||||
|     String completion; | ||||
|     if (suggestion.ends_with(".h") && completion_kind == GUI::AutocompleteProvider::CompletionKind::SystemInclude) | ||||
|         completion = String::formatted("{}{}", suggestion, ">"); | ||||
|     else if (suggestion.ends_with(".h") && completion_kind == GUI::AutocompleteProvider::CompletionKind::ProjectInclude) | ||||
|         completion = String::formatted("{}{}", suggestion, "\""); | ||||
|     else | ||||
|         completion = suggestion; | ||||
| 
 | ||||
|     m_editor->insert_at_cursor_or_replace_selection(completion); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 thislooksfun
						thislooksfun