Open phizch opened 1 year ago
I've mostly fixed it here.
One case that still doesn't work perfectly is when
With my fix, at least any text on subsequent lines are kept in the copy.
I haven't submitted a pull request yet, since I'm a total n00b when it comes to git.. Does it involve just the latest commit on my branch, or is it the entire history of that branch? The reason I ask is that I first did some experimentation, and then in later commits I removed the experiments again.
Tldr; the latest commit is fairly clean, but if a pull request involves the entire branch, it might be better if I squash the commits first.
I thought I checked first, but I must have been tired... This bug relates to #105 and #96.
I just got the same exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: length
at Microsoft.VisualStudio.Text.Span..ctor(Int32 start, Int32 length)
at Tweakster.Tweaks.Editor.CopyWithoutIndentation.ExecuteCommand(CopyCommandArgs args, CommandExecutionContext executionContext) in C:\projects\tweakster\src\TweaksterShared\Tweaks\Editor\CopyWithoutIndentation.cs:line 84
at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.<>c__DisplayClass15_1`1.<ExecuteStartingAtIndex>b__0()
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate`1 exceptionFilter)
I'm not sure what I did, but I think I created a new .http
file.
Environment:
Visual Studio version 17.7.4
Tweaks 2022 version 1.1.143
Describe the bug
If the indentations of the lines of text to be copied differ, too much or too little will be copied. If the first line's indentation are 2 tabs and the second has 8 spaces, the second line will be copied with 6 spaces. Even worse, if the first line's indentation are 8 spaces and the second line has 2 tabs, 6 characters of the second line won't be copied.
I watched the YT video where this feature was created and noticed it. I then tried it myself, and saw that the bug is still present.
To Reproduce
In the screenshots whitespace is represented as
·
for space, and→
for tab:Open a text file in Visual Studio and paste the following text:
With visible white space and a tab size of 4 it looks like this:![image](https://user-images.githubusercontent.com/10700161/207504963-a2d60961-94b7-4410-9b05-6527a861d253.png)
Select starting with "Does" and ending after "LGTM"
Press
Ctrl+C
to copy.Move to the start of a blank line and press
Ctrl+V
to paste.Actual behavior
The pasted text look like this:
Expected behavior
The text should be copied correctly
Additional context
The reason for the bug is that only the count of whitespace characters are taken into account, not the actual column.
https://github.com/madskristensen/Tweakster/blob/4b82c8219ca2ba13f78a570c073ee538ea9ae782/src/TweaksterShared/Tweaks/Editor/CopyWithoutIndentation.cs#L62
https://github.com/madskristensen/Tweakster/blob/4b82c8219ca2ba13f78a570c073ee538ea9ae782/src/TweaksterShared/Tweaks/Editor/CopyWithoutIndentation.cs#L84