Browse Source

Autocompletion: Override context for preload

HolonProduction 5 months ago
parent
commit
c00518eec7
2 changed files with 3 additions and 2 deletions
  1. 1 2
      modules/gdscript/gdscript_editor.cpp
  2. 2 0
      modules/gdscript/gdscript_parser.cpp

+ 1 - 2
modules/gdscript/gdscript_editor.cpp

@@ -878,8 +878,7 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, HashMap<St
 		if (requires_type && !ClassDB::is_parent_class(p_dir->get_file_type(i), p_required_type)) {
 		if (requires_type && !ClassDB::is_parent_class(p_dir->get_file_type(i), p_required_type)) {
 			continue;
 			continue;
 		}
 		}
-		ScriptLanguage::CodeCompletionOption option(p_dir->get_file_path(i), ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH);
-		option.insert_text = option.display.quote(quote_style);
+		ScriptLanguage::CodeCompletionOption option(p_dir->get_file_path(i).quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH);
 		r_list.insert(option.display, option);
 		r_list.insert(option.display, option);
 	}
 	}
 
 

+ 2 - 0
modules/gdscript/gdscript_parser.cpp

@@ -3487,6 +3487,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_preload(ExpressionNode *p_
 
 
 	if (preload->path == nullptr) {
 	if (preload->path == nullptr) {
 		push_error(R"(Expected resource path after "(".)");
 		push_error(R"(Expected resource path after "(".)");
+	} else if (preload->path->type == Node::LITERAL) {
+		override_completion_context(preload->path, COMPLETION_RESOURCE_PATH, preload);
 	}
 	}
 
 
 	pop_completion_call();
 	pop_completion_call();