-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unwanted extra spaces when pasting code with JSDoc #136579
Conversation
I realized the unit test didn't actually work properly, so I re-wrote it and updated the comment above with how to run it. |
When someone does review this, I just wanted to point out that reviewing with ignored whitespace will make it easier. |
I rebased this to fix merge conflicts. It is ready for review. |
🥲 |
I fixed the merge conflicts again. Hopefully this can get reviewed soon. |
@hediet @sandy081 Sorry if I am disturbing you. I just picked you, because you seem to be committing a lot, even though you may not been responsible. This pull request seems to be a fix for a bug #119225 which is very annoying. The pull request has been open and actively maintained for over a year. Could you please give any insight into your working process in order to shed some light onto when the bug might eventually be fixed? Is there anything I could do to contribute? |
What happens with this PR, when you paste this:
into a class that already has some indentation? |
Is this a general question or addressing me? In the latter case, I need to amend my previous comment about the information that I have not built a version of VScode with the PR merged in and therefore deliberately wrote "pull-request seems to be a fix". I am confident, however, that @ssigwart would answer the question given that he contributed the code. |
Thanks for responding, @hediet! The bug is that when you paste the code you quoted in a JavaScript file, it shows up like this: /**
* Function
*/
public func1(): number
{
return 1;
} Notice the extra spaces in front of "public" and the lines below it. With this PR, it gets pastes without adding the spaces. I think you are might be asking specifically if it will still function properly if you try to paste it where you expect an extra tab in front of every line. It's been a long time since I wrote this, but I'm fairly certain that works too. I can try to verify that tonight when I get back onto the computer I wrote this patch on. |
@hediet, I tested my branch. If there's existing indentation, it behaves the same way as before this change, so it seems good to me for this branch. It looks like the bug with the extra spaces only happens when there's no indentation and that's what this PR fixes. |
Fwiw I'm also seeing an extra space when there is already an indentation, and if the line being pasted at is already indented formatting gets even more broken. To be clear, this recording was made in the latest stable version of vscode that does not contain the fix of this PR yet. Screen.Recording.2022-11-17.at.11.59.49.mp4.mp4 |
@jespertheend, thanks for the recording. I'm not seeing the same behavior on the stable version of VS Code. Maybe it's different settings. Can you include two things so I can test it better?
|
I'm seeing the same behaviour in an incognito window on vscode.dev. To reproduce:
|
Ah and my clipboard contains this (encoded as javascript string) ' /**\n * @param {number} x \n * @param {string} y \n */\n bar(x, y) {\n\n }\n' |
Thanks, @jespertheend. I tested with my branch and it does solve that as well. |
@hediet Thanks a lot for reacting to my request to have a look at this pull request! And some extra thanks for doing it so quickly. I really appreciate that. |
I've been waiting for this moment for so long 🥲 |
Thank you so much, @hediet and @joaomoreno. What is the proper way to get attention on PRs? I have several that are over a year old where I haven't heard any feedback. In particular, there are 3 about code formatting (#136572, #136577, #136593) that would fix some annoying issues that I and I'm guessing others deal with daily. |
I can try to look at some of them some time. |
This PR fixes #119225. It prevents an extra space from being inserted after JavaDoc style comments.
To test, you can paste something like this into a typescript file.
I also added a test that can be run with:
./scripts/test.sh --glob **/indentation.test.js --grep=119225