Bug 442468 - Running a formatter as external tool prevents usage of Ctrl+Z
Summary: Running a formatter as external tool prevents usage of Ctrl+Z
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-15 09:19 UTC by Derek Christ
Modified: 2022-01-09 20:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Derek Christ 2021-09-15 09:19:32 UTC
SUMMARY
Running a formatter as an external tool has the ability to save the current file, apply the tool, and reloading it afterwards.
For formatting this works great but the reloading of the file wipes the Ctrl+Z buffer and its no longer possible to revert stuff that happened before the formatting. 

STEPS TO REPRODUCE
1. Make some changes to a file
2. Run the clang-format formatter tool on the whole file
3. Reverting changes before the formatting with Ctrl+Z is no longer possible.

OBSERVED RESULT
Ctrl+Z does nothing, because the file was reloaded.

EXPECTED RESULT
It should still be possible to revert old changes.
Other code editors I know of just revert the whole formatting when the user presses Ctrl+Z right after formatting. All other changes before that are also revertable.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20210913
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Comment 1 Waqar Ahmed 2022-01-09 20:10:40 UTC
You can change the external tool to not reload the document and change the command to output the text to stdout. Then choose the "replace text" option..

What that will do is replace the document's text with the text provided by your formatter. This seems to not work with every formatter as some for matters tend to include other stuff but with clang format it will work.

Reopen if you find it doesn't work.