-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Pasting after selecting html tag pastes twice #87067
Comments
Looks like a fault with this new 1.41 feature. cc @octref |
This is as-designed, since when you click after You can also turn this off with |
The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines. Happy Coding! |
In my opinion there is a bug here. Yes, the feature should create a mirror cursor on a matching tag, but when I'm pasting content with a leading space onto the opening tag, I'd expect the mirroring cursor to handle this like having typed the space manually. , the closing ">" is right behind the tag name and therefore I include leading spaces when copying, so I can just put the cursor right at the end of the tag and paste. Having to manually press space is an additional step in my workflow and makes this feature rather cumbersome.
|
Agreed this new feature should handle pasted content with leading space, just like if you typed it manually. Makes total sense |
@octref I'm sorry, but I don't understand how this can possibly be "as-designed"? Shouldn't pasting detect spaces as well? Also, many times when typing into an HTML tag it does not detect the space. I'll try to figure out if there's something repeatable that causes that issue to happen. |
OK I'll look into how to do this. Meanwhile you can press ESC before pasting for now. |
I was about to create a separate issue, but the following seems to be related to this behavior: Steps to reproduce:
Also, I concur—I don't see how this can possibly be intended behavior. |
Hmm.. certainly hiliting matching tags is HUGELY useful. But (certaintly for HTML code) I struggle to think of when I would be wanting to type or paste same test into both the open and closing tags.. |
@GaryHyland, this issue has been tagged as a bug by @octref. If you are willing to use Insiders you should get earlier access to a fix. |
Update: I looked through all mirror cursor issues. We'll explore #88424, which should fix some issues. I think there's no one correct solution here. I'll make #88424 work this way:
I want it to work this way, so you are sure about the effect of your action. Having two modes with clear distinction, where one always duplicates action and one always doesn't, is better than making it one mode, where you are unsure if the editor will do some "magic" for you. |
I do not share this sentiment. I'm fairly certain a user never wants to paste copied attributes into the closing tag, since it is always syntactically wrong. Hence you might as well rephrase your principle of consistency into:
|
Until this and #90146 (selecting causes selection of things outside the end tag as well) aren't fixed, I'm turning this feature off. It is a useful feature, but not usable right now. Looks like it wasn't tested in a real world scenario. also, the end tag will never have more things than the name of the tag itself, therefore pasting shouldn't be part of this feature. At most, when pasting, substitute the end tag with the resulting starting tag after pasting, ignoring the clipboard content. |
To your analogy, when I press enter/space/delete on here We never sell this feature as "magically editing HTML so the result is always semantically correct". What the feature does is just adding another multi-cursor. What I'll do is add clear UI indication that you are in this mode and your actions will be duplicated. What I won't do is to anticipate any keypress you can press to make HTML semantically invalid and create special-case fixes to prevent that. Finally this is made an opt-in feature. If you are ok with "Now I see two cursors, what I do will be duplicated, so I should do some action but not others, if I want my action not duplicated I'll ESC to dismiss the extra cursor", then you can turn it on. |
@octref are you the author of this feature? You have to listen to the community. A project changes based on different usages/requests. With all the bugs around this feature, I would doubt a lot of people will turn this feature on. If you keep saying this is by design, I will also just keep this feature off. The idea of changing the tag is genial and happens great in VS Razor, but somehow, I end up pressing CTRL+Z way more than I use to and it actually slows me down in my development with visual studio code. The reason I'm commenting on this issue is because I actually care about the feature, but if you just say this won't happen, then you care more about your code than admitting there might be errors and it should be fixed. |
@jsgoupil I'm saying it should happen in a consistent way, not a magical way. Your issue is #87732, which I plan to fix with #88424. The dilemma is:
A consistent solution is:
You can see how it works in Eclipse: What I'll not do is:
|
Don't re-invent the wheel here. Razor did it well. Your "mirror-cursor", is surely a great name, but the real feature (correct me if I'm wrong) is to update the matching HTML tag. The screenshot you pasted is handled well yes, because it's basically taking into account that in this particular language, space is not part of a variable. But I think this is quite digressing from the main problem. We are not refactoring here. We are just updating a matching HTML tag. |
That's not my point. I meant to say:
Consider this case. Suppose your paste content can either be:
Tell me, what should an editor do when pasting in That's why I'm making it explicit when editor is duplicating your changes and not. I never made the promise to say "this feature will always keep your HTML valid". |
@octref I may be a bit shortsighted, but what exactly this feature brings of new that F2 can't perform? I mean... F2 will change the end tag as well, won't it? Or is this just a WYSIWYG-ish refactoring? If that's the case, shouldn't F2 be changed to show the changes in real time instead of creating a new feature that tries to do something VSCode already can do? |
@octref Give it a shot with Razor. I would expect to work like Razor. No magic. If you paste any without a space, then you duplicate your paste in the closing tag. If I press space before I paste, then nothing is duplicated in the closing tag. |
Apparently this feature is ill advised to make use of multicursors in the first place. It should probably be re-implemented from scratch, this time as "When editing an HTML tag, copy whatever is the first word of the opening tag to the closing tag, no matter what part of and how the opening tag was edited". |
In tomorrow's insiders |
Steps to Reproduce:
<div></div>
<div
(put cursor before the end of opening tag)=> The pasted content will appear both after
<div
and after</div
. Example with pasting the contentclass="test"
will output<div class="test"></div class="test">
This didn't happen before, it is quite recent bug
The text was updated successfully, but these errors were encountered: