emoacht / TrimCopy

A Visual Studio extension to copy code block trimming leading white spaces while keeping indentation structure
https://marketplace.visualstudio.com/items?itemName=emoacht.TrimCopy
MIT License
4 stars 3 forks source link

Line ending at end of selection causes poor indent removal, and extra line copied #7

Open AArnott opened 1 year ago

AArnott commented 1 year ago

I love this extension, but it suffers from a bug that many editor-selection based extensions suffer from, related to the line ending that may be included at the end of the selection.

In the following example, I've very carefully omitted the trailing line ending. image

Then I execute the Trim Copy -> no indent command: image

This produces the desired result: image

But if I do things in a more natural way, by just selecting whole lines: image

Notice the very subtle selection difference where the trailing line ending is included.

Now when I paste this into Notepad, not only is the indentation not removed, an extra line has been pasted at the end: image

emoacht commented 1 year ago

Thank you for reporting. I have been trying to reproduce the issue (the second case) but I have not succeeded yet. Could you elaborate the way to reproduce the issue step by step? In addition, could you attach the .cs file used to reproduce the issue and the screenshot of settings of this extension?

AArnott commented 1 year ago

Thanks for looking. Here are the settings:

image

And here is a video of the repro steps.

https://user-images.githubusercontent.com/3548/236703153-7f1b2a2c-49b4-427f-b642-e933a947b371.mp4

Notice how after I hit the Copy command, the selection is extended to include the extra line and characters that end up being included in the pasted text into Notepad (which I don't want).