Merge pull request #10046 from Hinsbart/script_open_resource
ScriptEditor: ctrl+click can open scenes & resources.
This commit is contained in:
commit
c936e9946e
|
@ -634,7 +634,17 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptLanguage::LookupResult result;
|
ScriptLanguage::LookupResult result;
|
||||||
if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path().get_base_dir(), base, result) == OK) {
|
if (p_symbol.is_resource_file()) {
|
||||||
|
List<String> scene_extensions;
|
||||||
|
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
|
||||||
|
|
||||||
|
if (scene_extensions.find(p_symbol.get_extension())) {
|
||||||
|
EditorNode::get_singleton()->load_scene(p_symbol);
|
||||||
|
} else {
|
||||||
|
EditorNode::get_singleton()->load_resource(p_symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path().get_base_dir(), base, result) == OK) {
|
||||||
|
|
||||||
_goto_line(p_row);
|
_goto_line(p_row);
|
||||||
|
|
||||||
|
|
|
@ -4353,6 +4353,23 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
|
||||||
|
|
||||||
bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
|
bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
|
||||||
|
|
||||||
|
bool inside_quotes = false;
|
||||||
|
int qbegin, qend;
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
if (s[i] == '"') {
|
||||||
|
if (inside_quotes) {
|
||||||
|
qend = i;
|
||||||
|
inside_quotes = false;
|
||||||
|
if (col >= qbegin && col <= qend) {
|
||||||
|
return s.substr(qbegin, qend - qbegin);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qbegin = i + 1;
|
||||||
|
inside_quotes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (beg > 0 && s[beg - 1] > 32 && (symbol == _is_symbol(s[beg - 1]))) {
|
while (beg > 0 && s[beg - 1] > 32 && (symbol == _is_symbol(s[beg - 1]))) {
|
||||||
beg--;
|
beg--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue