godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Allow to use Ctrl + Enter to stage all files and commit in version control commit dock #2988

Closed Xrayez closed 3 years ago

Xrayez commented 3 years ago

Describe the project you are working on

Goost - Godot Engine Extension.

Describe the problem or limitation you are having in your project

I'm currently working on built-in Git integration in Goost as seen in goostengine/goost#98, and managed to resolve quite a bunch of usability issues so far even with v1.0 of the official Git plugin.

Yet one of the greatest productivity booster for me is having ability to immediately commit stuff. Currently, you have to:

  1. Stage all files.
  2. Write commit message.
  3. Use mouse to press the "Commit" button.

image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I suggest adding ability to use Ctrl + Enter shortcut which allows to save the time it takes to commit all files.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Just like in VS Code:

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, there's a way to inject special manager object which would listen to input events and delegate that to commit message box, or vice versa. But doing so would mean to rely on implementation detail, which is error-prone.

void EditorVCSInterfaceGitManager::_input(const Ref<InputEvent> &p_event) {
    ERR_FAIL_NULL(commit_msg_box);

    if (!commit_msg_box->has_focus() || commit_msg_box->get_text().empty()) {
        // Do not allow commits with empty message body either.
        // Unfortunately, `VersionControlEditorPlugin::_send_commit_msg` doesn't validate message text.
        return;
    }
    const Ref<InputEventKey> k = p_event;

    if (k.is_valid() && k->is_pressed()) {
        if (k->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_ENTER)) {
            VersionControlEditorPlugin::get_singleton()->call_deferred("_stage_all");
            VersionControlEditorPlugin::get_singleton()->call_deferred("_send_commit_msg");
        }
    }
}

Yet I'm not sure whether the same is possible to do via GDScript, might not be possible in fact.

Is there a reason why this should be core and not an add-on in the asset library?

VCS interface is already part of the editor.

Calinou commented 3 years ago

Feel free to open a pull request for this :slightly_smiling_face:

In general, any multiline field (= TextEdit) should be able to be submitted when pressing Ctrl + Enter.