godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.71k stars 20.12k forks source link

VS Code not opening from Godot on MacOS #82932

Closed mickeyordog closed 11 months ago

mickeyordog commented 11 months ago

Godot version

v4.1.1.stable.mono.official [bd6af8e0e]

System information

Godot v4.1.1.stable.mono - macOS 13.4.1 - Vulkan (Forward+) - integrated Apple M1 - Apple M1 (8 Threads)

Issue description

Attempting to open VS Code by clicking a script icon in the scene view, or double clicking a script in the FileSystem tab, does nothing. No error or anything is shown in the Godot console which makes this very difficult to debug.

All of the steps in the "using an external editor" docs have been followed. Opening VS Code outside of Godot and then opening my files there works as expected.

If you have any suggestions for debugging this, or any way to see what errors might be happening when I attempt to open VS Code, that would be greatly appreciated. I have viewed several different similar bug reports online but have been unable to resolve this problem.

Steps to reproduce

  1. Create a new project
  2. In editor settings: External editor: Visual Studio Code Custom Exec Path: /Applications/Visual Studio Code.app/Contents/MacOS/Electron Custom Exec Path: {project} --goto {file}: {line}:{col}

Minimal reproduction project

Can be seen from blank project following minimal steps on my machine

jackwilsdon commented 11 months ago

I can reproduce this with your exec flags, but removing the space between {file}: and {line}:{col} (making it {project} --goto {file}:{line}:{col} fixes it for me. That is also what is documented in the plugin README.

Does removing that space fix it for you?

mickeyordog commented 11 months ago

That didn't fix it unfortunately. I've also tried it with just {project} and with no custom exec path, which I believe is what's working properly when I open the same project on my Windows machine, but still doesn't work.

If you have any ideas for how I can test this, or even how I might be able to see any errors that might be generated, please let me know

jackwilsdon commented 11 months ago

Does running the following in Terminal correctly open VS Code for you?

/Applications/Visual Studio Code.app/Contents/MacOS/Electron /path/to/your/project --goto filename-in-your-project:1:1
mickeyordog commented 11 months ago

That command didn't, but I wrapped the VS Code path in quotes like so "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" /Users/mickey/Documents/GitHub/KeeperGodot/KeeperGodot --goto /Users/mickey/Documents/GitHub/KeeperGodot/KeeperGodot/scripts/Player.cs:1:1 And that worked properly. I went back and wrapped the exec path in quotes back in Godot to see if that would fix it, but still nothing.

jackwilsdon commented 11 months ago

Can you post the contents of your ~/Library/Application Support/Godot/editor_settings-4.tres?

mickeyordog commented 11 months ago

There doesn't appear to be a Godot directory inside ~/Library/Application Support/

jackwilsdon commented 11 months ago

That's a bit surprising. cat ~/Library/Application\ Support/Godot/editor_settings-4.tres | pbcopy should copy it to your clipboard - I'm not sure if it'll show up in Finder (Library is usually hidden).

mickeyordog commented 11 months ago

Oh sorry about that, wasn't looking in my user directory. Here is the contents:

[gd_resource type="EditorSettings" load_steps=9 format=3]

[sub_resource type="InputEventKey" id="InputEventKey_vfakf"]
device = -1
keycode = 82
unicode = 114

[sub_resource type="InputEventKey" id="InputEventKey_r84i3"]
keycode = 4194323

[sub_resource type="InputEventKey" id="InputEventKey_ltpy5"]
device = -1
physical_keycode = 93
unicode = 93

[sub_resource type="InputEventKey" id="InputEventKey_xmwow"]
keycode = 4194324

[sub_resource type="InputEventKey" id="InputEventKey_v2gof"]
device = -1
physical_keycode = 91
unicode = 91

[sub_resource type="InputEventKey" id="InputEventKey_hkq52"]
device = -1
keycode = 65
unicode = 97

[sub_resource type="InputEventKey" id="InputEventKey_ew7q0"]
device = -1
keycode = 83
unicode = 115

[sub_resource type="InputEventKey" id="InputEventKey_qviue"]
device = -1
keycode = 68
unicode = 100

[resource]
interface/editor/code_font_size = 15.0
interface/theme/base_color = Color(0.21, 0.24, 0.29, 1)
interface/theme/accent_color = Color(0.44, 0.73, 0.98, 1)
interface/theme/contrast = 0.3
text_editor/theme/highlighting/symbol_color = Color(0.67, 0.79, 1, 1)
text_editor/theme/highlighting/keyword_color = Color(1, 0.44, 0.52, 1)
text_editor/theme/highlighting/control_flow_keyword_color = Color(1, 0.55, 0.8, 1)
text_editor/theme/highlighting/base_type_color = Color(0.26, 1, 0.76, 1)
text_editor/theme/highlighting/engine_type_color = Color(0.56, 1, 0.86, 1)
text_editor/theme/highlighting/user_type_color = Color(0.78, 1, 0.93, 1)
text_editor/theme/highlighting/comment_color = Color(0.8025, 0.81, 0.8225, 0.5)
text_editor/theme/highlighting/string_color = Color(1, 0.93, 0.63, 1)
text_editor/theme/highlighting/background_color = Color(0.1155, 0.132, 0.1595, 1)
text_editor/theme/highlighting/completion_background_color = Color(0.21, 0.24, 0.29, 1)
text_editor/theme/highlighting/completion_selected_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/completion_existing_color = Color(1, 1, 1, 0.14)
text_editor/theme/highlighting/completion_font_color = Color(0.8025, 0.81, 0.8225, 1)
text_editor/theme/highlighting/text_color = Color(0.8025, 0.81, 0.8225, 1)
text_editor/theme/highlighting/line_number_color = Color(0.8025, 0.81, 0.8225, 0.5)
text_editor/theme/highlighting/safe_line_number_color = Color(0.8025, 0.972, 0.8225, 0.75)
text_editor/theme/highlighting/caret_color = Color(1, 1, 1, 1)
text_editor/theme/highlighting/selection_color = Color(0.44, 0.73, 0.98, 0.4)
text_editor/theme/highlighting/brace_mismatch_color = Color(1, 0.47, 0.42, 1)
text_editor/theme/highlighting/current_line_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/line_length_guideline_color = Color(0.21, 0.24, 0.29, 1)
text_editor/theme/highlighting/word_highlighted_color = Color(1, 1, 1, 0.07)
text_editor/theme/highlighting/number_color = Color(0.63, 1, 0.88, 1)
text_editor/theme/highlighting/function_color = Color(0.34, 0.7, 1, 1)
text_editor/theme/highlighting/member_variable_color = Color(0.736, 0.88, 1, 1)
text_editor/theme/highlighting/mark_color = Color(1, 0.47, 0.42, 0.3)
text_editor/theme/highlighting/breakpoint_color = Color(1, 0.47, 0.42, 1)
text_editor/theme/highlighting/code_folding_color = Color(1, 1, 1, 0.27)
text_editor/theme/highlighting/search_result_color = Color(1, 1, 1, 0.07)
text_editor/appearance/minimap/show_minimap = false
text_editor/appearance/whitespace/draw_tabs = false
text_editor/behavior/navigation/scroll_past_end_of_file = true
text_editor/behavior/files/auto_reload_scripts_on_external_change = true
text_editor/completion/code_complete_delay = 0.01
text_editor/completion/add_type_hints = true
debugger/auto_switch_to_remote_scene_tree = true
asset_library/available_urls = {
"godotengine.org (Official)": "https://godotengine.org/asset-library/api"
}
asset_library/use_threads = true
export/android/android_sdk_path = ""
export/android/debug_keystore = ""
export/android/debug_keystore_user = "androiddebugkey"
export/android/debug_keystore_pass = "android"
export/android/force_system_user = false
export/android/shutdown_adb_on_exit = true
export/android/one_click_deploy_clear_previous_install = false
export/macos/rcodesign = ""
export/web/http_host = "localhost"
export/web/http_port = 8060
export/web/use_tls = false
export/web/tls_key = ""
export/web/tls_certificate = ""
export/windows/rcedit = ""
export/windows/osslsigncode = ""
export/windows/wine = ""
interface/editor/save_on_focus_loss = false
interface/editor/show_update_spinner = false
interface/editor/update_continuously = false
interface/editor/localize_settings = true
interface/scene_tabs/restore_scenes_on_load = true
interface/inspector/default_property_name_style = 1
interface/inspector/default_float_step = 0.001
interface/inspector/disable_folding = false
interface/inspector/auto_unfold_foreign_scenes = true
interface/inspector/horizontal_vector2_editing = false
interface/inspector/horizontal_vector_types_editing = true
interface/inspector/open_resources_in_current_inspector = true
interface/inspector/resources_to_open_in_new_inspector = PackedStringArray("Script", "MeshLibrary")
interface/inspector/default_color_picker_mode = 0
interface/inspector/default_color_picker_shape = 3
_default_feature_profile = "mickey_profile"
interface/editors/show_scene_tree_root_selection = true
interface/editors/derive_script_globals_by_name = true
docks/scene_tree/ask_before_deleting_related_animation_tracks = true
_use_favorites_root_selection = false
filesystem/file_server/port = 6010
filesystem/file_server/password = ""
editors/3d/manipulator_gizmo_size = 80
editors/3d/manipulator_gizmo_opacity = 0.9
editors/3d/navigation/show_viewport_rotation_gizmo = true
editors/3d/navigation/show_viewport_navigation_gizmo = false
text_editor/behavior/files/auto_reload_and_parse_scripts_on_save = true
text_editor/behavior/files/open_dominant_script_on_scene_change = true
text_editor/external/use_external_editor = true
text_editor/external/exec_path = "/Applications/Visual Studio Code.app/Contents/MacOS/Electron"
text_editor/script_list/script_temperature_enabled = true
text_editor/script_list/script_temperature_history_size = 15
text_editor/script_list/group_help_pages = true
text_editor/script_list/sort_scripts_by = 0
text_editor/script_list/list_script_names_as = 0
text_editor/external/exec_flags = "{project} --goto {file}:{line}:{col}"
version_control/username = ""
version_control/ssh_public_key_path = ""
version_control/ssh_private_key_path = ""
editors/bone_mapper/handle_colors/unset = Color(0.3, 0.3, 0.3, 1)
editors/bone_mapper/handle_colors/set = Color(0.1, 0.6, 0.25, 1)
editors/bone_mapper/handle_colors/missing = Color(0.8, 0.2, 0.8, 1)
editors/bone_mapper/handle_colors/error = Color(0.8, 0.2, 0.2, 1)
network/debug_adapter/remote_port = 6006
network/debug_adapter/request_timeout = 1000
network/debug_adapter/sync_breakpoints = false
editors/3d_gizmos/gizmo_colors/path = Color(0.5, 0.5, 1, 0.8)
editors/3d_gizmos/gizmo_colors/skeleton = Color(1, 0.8, 0.4, 1)
editors/3d_gizmos/gizmo_colors/selected_bone = Color(0.8, 0.3, 0, 1)
editors/3d_gizmos/gizmo_settings/bone_axis_length = 0.1
editors/3d_gizmos/gizmo_settings/bone_shape = 1
editors/3d_gizmos/gizmo_colors/csg = Color(0, 0.4, 1, 0.15)
editors/grid_map/editor_side = 1
editors/grid_map/palette_min_width = 230
editors/grid_map/preview_size = 64
export/ssh/ssh = ""
export/ssh/scp = ""
network/language_server/remote_host = "127.0.0.1"
network/language_server/remote_port = 6005
network/language_server/enable_smart_resolve = true
network/language_server/show_native_symbols_in_editor = false
network/language_server/use_thread = false
filesystem/import/blender/rpc_port = 6011
filesystem/import/blender/rpc_server_uptime = 5
filesystem/import/blender/blender3_path = ""
filesystem/import/fbx/fbx2gltf_path = ""
dotnet/editor/external_editor = 4
dotnet/editor/custom_exec_path = "/Applications/Visual Studio Code.app/Contents/MacOS/Electron"
dotnet/editor/custom_exec_path_args = "{project} --goto {file}:{line}:{col}"
dotnet/build/verbosity_level = 2
dotnet/build/no_console_logging = false
dotnet/build/create_binary_log = false
editors/3d_gizmos/gizmo_colors/camera = Color(0.8, 0.4, 0.8, 1)
editors/3d_gizmos/gizmo_colors/stream_player_3d = Color(0.4, 0.8, 1, 1)
editors/3d_gizmos/gizmo_colors/occluder = Color(0.8, 0.5, 1, 1)
editors/3d_gizmos/gizmo_colors/visibility_notifier = Color(0.8, 0.5, 0.7, 1)
editors/3d_gizmos/gizmo_colors/particles = Color(0.8, 0.7, 0.4, 1)
editors/3d_gizmos/gizmo_colors/particle_attractor = Color(1, 0.7, 0.5, 1)
editors/3d_gizmos/gizmo_colors/particle_collision = Color(0.5, 0.7, 1, 1)
editors/3d_gizmos/gizmo_colors/reflection_probe = Color(0.6, 1, 0.5, 1)
editors/3d_gizmos/gizmo_colors/decal = Color(0.6, 0.5, 1, 1)
editors/3d_gizmos/gizmo_colors/voxel_gi = Color(0.5, 1, 0.6, 1)
editors/3d_gizmos/gizmo_colors/lightmap_lines = Color(0.5, 0.6, 1, 1)
editors/3d_gizmos/gizmo_colors/lightprobe_lines = Color(0.5, 0.6, 1, 1)
editors/3d_gizmos/gizmo_colors/joint_body_a = Color(0.6, 0.8, 1, 1)
editors/3d_gizmos/gizmo_colors/joint_body_b = Color(0.6, 0.9, 1, 1)
editors/3d_gizmos/gizmo_colors/fog_volume = Color(0.5, 0.7, 1, 1)
text_editor/help/sort_functions_alphabetically = true
text_editor/theme/highlighting/gdscript/function_definition_color = Color(0.4, 0.9, 1, 1)
text_editor/theme/highlighting/gdscript/global_function_color = Color(0.64, 0.64, 0.96, 1)
text_editor/theme/highlighting/gdscript/node_path_color = Color(0.72, 0.77, 0.49, 1)
text_editor/theme/highlighting/gdscript/node_reference_color = Color(0.39, 0.76, 0.35, 1)
text_editor/theme/highlighting/gdscript/annotation_color = Color(1, 0.7, 0.45, 1)
text_editor/theme/highlighting/gdscript/string_name_color = Color(1, 0.76, 0.65, 1)
shortcuts = [{
"name": "canvas_item_editor/scale_mode",
"shortcuts": [SubResource("InputEventKey_vfakf")]
}, {
"name": "tiles_editor/select_next_layer",
"shortcuts": [SubResource("InputEventKey_r84i3"), SubResource("InputEventKey_ltpy5")]
}, {
"name": "tiles_editor/select_previous_layer",
"shortcuts": [SubResource("InputEventKey_xmwow"), SubResource("InputEventKey_v2gof")]
}, {
"name": "tiles_editor/selection_tool",
"shortcuts": [SubResource("InputEventKey_hkq52")]
}, {
"name": "tiles_editor/paint_tool",
"shortcuts": [SubResource("InputEventKey_ew7q0")]
}, {
"name": "tiles_editor/picker",
"shortcuts": [SubResource("InputEventKey_qviue")]
}]
metadata/script_setup_templates_dictionary = {
"": "0ObjectEmpty",
"Area2D": "0NodeDefault",
"Camera2D": "0NodeDefault",
"CharacterBody2D": "0CharacterBody2DBasic Movement",
"Node": "0ObjectEmpty",
"R": "0ObjectEmpty",
"Re": "0ObjectEmpty",
"Res": "0ObjectEmpty",
"Reso": "0ObjectEmpty",
"Resou": "0ObjectEmpty",
"Resour": "0ObjectEmpty",
"Resourc": "0ObjectEmpty",
"Resource": "0ObjectEmpty",
"Sprite2D": "0ObjectEmpty",
"Sprite2Dj": "0ObjectEmpty",
"TileMap": "0NodeDefault"
}
metadata/export_template_download_directory = "/Users/mickey/Library/Caches/Godot"
metadata/script_setup_use_script_templates = true
jackwilsdon commented 11 months ago

How strange - if I replace my editor_settings-4.tres with that, it opens as expected when clicking a GDScript file. I'm on macOS 13.5.2, but I can't imagine that making a difference.

mickeyordog commented 11 months ago

Yeah I just updated my Mac, still not working.

Would you mind pointing me to where this is being handled in the source code if you know?

jackwilsdon commented 11 months ago

Handling for opening files via the script icon in the scene tree / file in the file system panel is here: https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/plugins/script_editor_plugin.cpp#L2284-L2344

There's also separate handling for right clicking a script and pressing "Open in External Program": https://github.com/godotengine/godot/blob/6916349697a4339216469e9bf5899b983d78db07/editor/filesystem_dock.cpp#L2116-L2126

Out of curiosity, does "Open in External Program" (on a script) work for you?

mickeyordog commented 11 months ago

Thanks. Hmm, open in external program does work for me

mickeyordog commented 11 months ago

Ok finally figured it out, it was because I disabled the script editor in Godot. No idea why that broke it, but I put the editor tab back in and now it's working.