You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running gdscript-format-buffer, once the formatting operation completed, does not revert the buffer instantly, letting you type characters that can get lost. That is unlike gdscript-format-region, that locks Emacs until the formatter finished its work (which takes a split second now).
The text was updated successfully, but these errors were encountered:
When using gdscript-format-buffer from "current buffer" then the comint stuff seems overkill. A possibly naive, but functional fix is
(defun gdscript-format-buffer()
"Format the current buffer using `gdformat'."
(interactive)
(save-mark-and-excursion
(mark-whole-buffer)
(gdscript-format-region))
(when (buffer-modified-p)
(save-buffer)))
It's not saving the point for some reason but it's a start.
(ps I dont think it should auto save - if I was to PR this I would suggest we remove the buffer-modified-p check - I like to save the buffer myself )
gdscript-format--save-buffer saves the buffer before running gdformat, which is necessary: if you run gdformat on a file with unsaved changes, you'll lose your work.
There are some improvements that comint brought that were a pain before, like gdformat inserting ['-'] at the start of the file. It makes error handling consistent in the package.
Sure, it was more work, but @VlachJosef did it and did it well. This issue is just a detail: you can type a few characters while gdformat is running in the background and have the buffer revert after a second, which doesn't feel great.
Note: instead of save-mark-and-excursion, I'd recommend using buffer-end, which returns a position without changing the state of point.
Sure, my observation is not about gdscript-format--save-buffer - just the interactive call to gdscript-format-buffer running on a buffer and not a file. I'll have a look at buffer-end, thanks for the pointer.
Running
gdscript-format-buffer
, once the formatting operation completed, does not revert the buffer instantly, letting you type characters that can get lost. That is unlikegdscript-format-region
, that locks Emacs until the formatter finished its work (which takes a split second now).The text was updated successfully, but these errors were encountered: