mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2025-12-31 21:48:34 +03:00
Fix scene and script selection not aborting when pressing C-g (#90)
* abort run if user cancels (C-g) a scene/script selection. * removed todo
This commit is contained in:
@@ -102,20 +102,26 @@ When run with prefix argument, it offers extra debug options to choose from."
|
||||
(defun gdscript-godot-run-current-scene ()
|
||||
"Run the current script file in Godot Engine. Use the universal prefix (C-u) to force a scene select."
|
||||
(interactive)
|
||||
(gdscript-godot--run-command (gdscript-godot--select-scene current-prefix-arg)))
|
||||
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
|
||||
(when scene
|
||||
(gdscript-godot--run-command scene))))
|
||||
|
||||
(defun gdscript-godot-run-current-scene-debug ()
|
||||
"Run the current script file in Godot Engine.
|
||||
|
||||
When run with prefix argument, it offers extra debug options to choose from."
|
||||
(interactive)
|
||||
(gdscript-godot--debug-options-handler debug-options
|
||||
(gdscript-godot--run-command "-d" debug-options (gdscript-godot--select-scene))))
|
||||
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
|
||||
(when scene
|
||||
(gdscript-godot--debug-options-handler debug-options
|
||||
(gdscript-godot--run-command "-d" debug-options scene)))))
|
||||
|
||||
(defun gdscript-godot-edit-current-scene ()
|
||||
"Run the current script file in Godot Engine."
|
||||
(interactive)
|
||||
(gdscript-godot--run-command "-e" (gdscript-godot--select-scene current-prefix-arg)))
|
||||
(let ((scene (gdscript-godot--select-scene current-prefix-arg)))
|
||||
(when scene
|
||||
(gdscript-godot--run-command "-e" scene))))
|
||||
|
||||
(defun gdscript-godot--select-scene (&optional select-scene)
|
||||
"Select scene to run"
|
||||
|
||||
@@ -46,12 +46,13 @@ If current buffer is not visiting scene file return nil."
|
||||
(when (file-exists-p scene-name) scene-name))))
|
||||
|
||||
(defun gdscript-project--select-scene ()
|
||||
"Find all scenes files and let user choose one."
|
||||
"Find all scenes files and let user choose one. Return `nil' if user cancels selection."
|
||||
(message "selecting scene")
|
||||
(let* ((rl (gdscript-util--find-project-configuration-file))
|
||||
(scene-list (mapcar (lambda (x) (file-relative-name x rl)) (directory-files-recursively rl ".*.tscn" t)))
|
||||
(prompt (format "Select scene to run" (buffer-name))))
|
||||
(gdscript-util--read scene-list prompt)))
|
||||
(prompt (format "Select scene to run" (buffer-name)))
|
||||
(selected-scene (gdscript-util--read scene-list prompt)))
|
||||
selected-scene))
|
||||
|
||||
(defun gdscript-project--current-buffer-script ()
|
||||
"Return the name of current script.
|
||||
@@ -70,7 +71,7 @@ If current buffer is not visiting script file return nil."
|
||||
(unwind-protect
|
||||
(let* ((prompt (format "Buffer %s is not script file, select script to run" (buffer-name)))
|
||||
(script-name (gdscript-util--read gdscript-project--script-list prompt)))
|
||||
(gdscript-godot--run-script script-name))
|
||||
(when script-name (gdscript-godot--run-script script-name)))
|
||||
(when hydra-open (gdscript-hydra--menu/body)))))
|
||||
|
||||
(defun gdscript-project--ag-cleanup ()
|
||||
|
||||
@@ -142,11 +142,9 @@ For example:
|
||||
|
||||
(defun gdscript-util--read (items &optional prompt)
|
||||
"Let's choose single item from ITEMS from mini-buffer.
|
||||
|
||||
PROMPT is prompt for read command."
|
||||
(message "gdscript util read")
|
||||
(let ((p (if prompt prompt "Options")))
|
||||
(cond ((and (featurep 'projectile) )
|
||||
PROMPT is prompt for read command. Return `nil' if user aborts."
|
||||
(let* ((p (if prompt prompt "Options"))
|
||||
(result (cond ((and (featurep 'projectile) )
|
||||
(projectile-completing-read (format "%s: " p) items))
|
||||
((fboundp 'ivy-read)
|
||||
(ivy-read (format "%s: " p) items))
|
||||
@@ -154,6 +152,7 @@ PROMPT is prompt for read command."
|
||||
(ido-completing-read (format "%s: " p) items))
|
||||
(t
|
||||
(completing-read (format "%s (hit TAB to auto-complete): " p) items nil t)))))
|
||||
(if quit-flag nil result)))
|
||||
|
||||
(provide 'gdscript-utils)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user