Bug 422730 - "Trim leading spaces" shouldn't apply to multiline copies
Summary: "Trim leading spaces" shouldn't apply to multiline copies
Status: RESOLVED WORKSFORME
Alias: None
Product: konsole
Classification: Applications
Component: copy-paste (show other bugs)
Version: 20.04.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-10 09:36 UTC by Mathias Stearn
Modified: 2020-12-01 04:33 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Stearn 2020-06-10 09:36:59 UTC
SUMMARY

Trim leading spaces is a useful setting when copying from the middle of a line since there seems to be a 50% chance that I accidentally select the space before the word I want to start copying at. It is also nice when I copy a single line of code, since I can just triple click and usually don't want the indentation in that case. However it is very problematic when copying multiple lines of code, since it strips all indentation. 

IMO it would be best to ignore a leading or trailing newline when deciding whether a selection is multi-line. Eg when copying "\n   asdf\n", I think I'd expect just "asdf", but with "  foo:\n    bar\n", I'd expect "  foo:\n    bar" (assuming trim trailing spaces was enabled). A possible enhancement would be to dedent all lines by the indentation of the least indented line, possibly only if there are no lines less indented than the first. Then "  foo:\n    bar\n" would become "foo:\n  bar". Not 100% sure if that is a good idea or not.

For multiline strings, I'm not sure whether "trim trailing spaces" should apply to each line or just the last one, although I lean toward trimming all lines. IIRC there are some cases where programs write gratuitous extra spaces at the end of lines, and I can't think of any case where I'd actually want to preserve them.

STEPS TO REPRODUCE
1. enable the "trim leading spaces setting"
2. cat a file with some well-indented code, using python for maximum fun
3. copy several lines of code, such as a whole function
4. paste it somewhere
5. curse loudly while reindenting it all

OBSERVED RESULT

indentation is removed and all code starts at column 0

EXPECTED RESULT

indentation should be preserved
Comment 1 Justin Zobel 2020-11-01 05:05:19 UTC
Mathis I've just tested this on KDE Neon Unstable and can't reproduce the issue.

Can you please retest and confirm if this is still an issue, thanks.
Comment 2 Bug Janitor Service 2020-11-16 04:33:44 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Bug Janitor Service 2020-12-01 04:33:49 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!