Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python script editor "open in external editor" action #57682

Merged
merged 4 commits into from
Jun 7, 2024

Conversation

nyalldawson
Copy link
Collaborator

When a system has a EDITOR environment variable set to either an invalid editor, or an editor which requires a terminal (eg nano/vim), then fallback to the QDesktopServices approach to opening the script

Avoids this button doing nothing.

@github-actions github-actions bot added this to the 3.38.0 milestone Jun 6, 2024
@nyalldawson nyalldawson closed this Jun 6, 2024
@nyalldawson nyalldawson reopened this Jun 6, 2024
Copy link

github-actions bot commented Jun 6, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 16a1ef9)

When a system has a EDITOR environment variable set to either
an invalid editor, or an editor which requires a terminal (eg
nano/vim), then fallback to the QDesktopServices approach
to opening the script

Avoids this button doing nothing.
…itorWidget

This allows the editor to be opened in a proper detached process,
avoiding the editor being closed when QGIS is exited.

Move to a blocklist for terminal text editors instead of the fragile
polling approach (which eg doesn't work if the editor is set to
pycharm)
@nyalldawson nyalldawson force-pushed the fix_external_editor branch from e1f51c3 to 9559a26 Compare June 7, 2024 06:47
@nyalldawson
Copy link
Collaborator Author

@elpaso i've changed the approach here a bit, do you mind re-reviewing?

@nyalldawson nyalldawson merged commit 9eef441 into qgis:master Jun 7, 2024
29 checks passed
@nyalldawson
Copy link
Collaborator Author

Thanks @elpaso!

@nyalldawson nyalldawson deleted the fix_external_editor branch June 7, 2024 10:46
@qgis-bot
Copy link
Collaborator

qgis-bot commented Jun 7, 2024

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 7271220ce49... Move file path handling for console editor to QgsCodeEditorWidget
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging python/console/console.py
[backport-57682-to-queued_ltr_backports 0916bd0aea1] Fix python script editor "open in external editor" action
 Author: Nyall Dawson <[email protected]>
 Date: Thu Jun 6 09:50:57 2024 +1000
 1 file changed, 16 insertions(+), 4 deletions(-)
CONFLICT (modify/delete): python/PyQt6/gui/auto_generated/codeeditors/qgscodeeditorwidget.sip.in deleted in HEAD and modified in 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget).  Version 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget) of python/PyQt6/gui/auto_generated/codeeditors/qgscodeeditorwidget.sip.in left in tree.
Auto-merging python/console/console.py
Auto-merging python/console/console_editor.py
CONFLICT (content): Merge conflict in python/console/console_editor.py
CONFLICT (modify/delete): python/gui/auto_generated/codeeditors/qgscodeeditorwidget.sip.in deleted in HEAD and modified in 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget).  Version 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget) of python/gui/auto_generated/codeeditors/qgscodeeditorwidget.sip.in left in tree.
CONFLICT (modify/delete): src/gui/codeeditors/qgscodeeditorwidget.cpp deleted in HEAD and modified in 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget).  Version 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget) of src/gui/codeeditors/qgscodeeditorwidget.cpp left in tree.
CONFLICT (modify/delete): src/gui/codeeditors/qgscodeeditorwidget.h deleted in HEAD and modified in 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget).  Version 7271220ce49 (Move file path handling for console editor to QgsCodeEditorWidget) of src/gui/codeeditors/qgscodeeditorwidget.h left in tree.

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-57682-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 6f5cb77cd9287ae79bfdf98bc34fafe03dd4c78c,7271220ce493c2b4be2a16a2306f9c92afcd9d40,9559a2606454f8da135ae28e8e29c319151a4954,16a1ef9477bcfddbb0441f23191ebca8b8c32568
# Push it to GitHub
git push --set-upstream origin backport-57682-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-57682-to-queued_ltr_backports.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports failed backport The automated backport attempt failed, needs a manual backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants