godotengine / godot

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

External text editor does not open unless Godot quits #24756

Open Rubonnek opened 5 years ago

Rubonnek commented 5 years ago

Godot version:

3.2 branch at commit 68013d23932688e57b489600f4517dd280edc464

OS/device including version:

Arch Linux x86_64 - gcc (GCC) 8.2.1 20181127

Issue description:

After trying to run the Finite State Machine example in the demos, which currently has faulty GDScript code, I expected my external editor to run but this was not the case. I placed some debugging code in OS_Unix::execute and turns out that the execvp attempt is actually another command:

Attempting to execute: /opt/godot/bin/godot.x11.opt.tools.64 --path /home/wilson/gitrepos/godot-demo-projects/2d/finite_state_machine --remote-debug 127.0.0.1:6007 --allow_focus_steal_pid 1863 --position 320,180 (null)

For some reason, whether the project was not stopped (i.e. if F8 is not pressed) or not, and Godot quits, the next time Godot opens, it attempts to run my external editor:

Attempting to execute: xterm -bg black -fg white -sl 100000 -e vim +"call cursor(0, 0) /home/wilson/gitrepos/godot-demo-projects/2d/finite_state_machine/player/weapon/sword.gd (null)

For some reason I also had to escape that + symbol with a backslash \ in the argument list within the editor.

For what is worth, here's the code I placed right before the execvp call in OS_Unix::execute:

        fprintf(stderr, "Attempting to execute:");
        for (int i = 0; i < args.size(); i++)
            fprintf(stderr, " %s", args[i]);
        fprintf(stderr, "\n");

Steps to reproduce:

Minimal reproduction project: See the Finite State Machine example in the godot-demo-repository repository at commit eb27a35a2d5212abfc516aa3c8fcb76c907155f0

akien-mga commented 4 years ago

Is this still reproducible in the current master branch / latest 3.2 builds?

Rubonnek commented 4 years ago

I'll test this next week against a master branch build.

Rubonnek commented 4 years ago

I can confirm this is still happening.

Here are the steps of what I did:

cd godot-demo-projects/2d/finite_state_machine
git checkout eb27a35a2d5212abfc516aa3c8fcb76c907155f0
git clean -xdff
git reset --hard

# External editor option was set to ON before launching godot the first time
# Exec Path and Exec flags are empty
godot -e 
# No external editor spawns as expected
# Update Exec Path and Exec Flags with correct external editor values
# Press F5 to attempt to run the game with fault GDScript
# Godot stops project as usual, but the External Editor does not open.
# Clicking on debug messages also do not open the editor -- I expected this to work at the very least
# Stop the game (F8)
# Press Ctrl-Q and exit the editor
godot -e
# Godot launches and spawns the external editor as soon as possible
# Clicking on warnings now opens the external editor like usual

Also the Exec Path and Exec Flags boxes are somewhat glitchy. The text inside them sometimes disappear all of a sudden when copy-pasting the Exec Path and Exec Flags values. I could not find a way to replicate this last small issue consistently.

Rubonnek commented 4 years ago

For what is worth, the {col} and {line} values do not seem to work when I use the following:

Exec Path: uxterm
Exec Flags: -bg black -fg white -sl 100000 -e vim \+"call cursor({line}, {col})" {file}

Here's how the show up in editor_settings-3.tres:

text_editor/external/exec_path = "uxterm"
text_editor/external/exec_flags = "-bg black -fg white -sl 100000 -e vim \\+\"call cursor({line}, {col})\" {file}"
KoBeWi commented 3 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

Rubonnek commented 3 years ago

Can confirm this is still happening in the 3.2 branch at commit 68013d23932688e57b489600f4517dd280edc464. After the faulty GDScript code is detected, Godot is still not opening up the external editor. Not even when restarting Godot now. I've updated the steps to reproduce accordingly.