-
Notifications
You must be signed in to change notification settings - Fork 803
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
Issues with FormatOnPaste into Visual F# editor #12158
Comments
I've noticed this strange loss of indentation on paster too in Visual Studio and it's really problematic. I can't believe we want it to be like this, so labelling as impact high |
@dsyme , I think what we do is correct ...
For refactoring functions this is great: Where it feels incorrect is when pasting to a new line: However, I don't really know of a heuristic to use that wouldn't be surprising in this case. I think we have perhaps done a bad job of educating, ourselves and others as to the paste behaviour. We should consider fixing the education, because the existing behaviour is reasonable and usefull. The alternative would be for us to blindly copy and paste ignoring indentation and simply reproducing whatever indentation exists in the code. I suspect that doing that would result in more work re-aligning than with the existing system. |
Can you look at the video below? I Ctrl-C to copy a line, then try to paste it at different column positions. Why does it lose indentation when I paste at column 0 and not at anywhere else? FSharp.-.Microsoft.Visual.Studio.Preview.Administrator.2021-11-04.21-49-51.mp4In this case, it's surely a bug that pasting at column zero is so different (and wrong). |
Note the behaviour is different when you select a line and when you Ctrl-C a line. The "select a line" results in an immensely confusing paste. I literally have no idea what I'm going to get: FSharp.-.Microsoft.Visual.Studio.Preview.Administrator.2021-11-04.21-54-26.mp4In this case the whole behaviour feels wrong. I just don't know what we're trying to achieve here or what the cognitive model is for what the user has copied. It seems the expectation that the user manually move the cursor to a column hoping that the paste will then indent, rather than the user pasting according to normal editor rules (e.g. VSCode) and then indenting manually. I really doubt there's any value in differing from VSCode for something so basic. It feels like we're trying to get structure-aware paste when we're just crossing our fingers that it's the right thing to do. Basically, it feels to me like we should turn this off. When did we even implement this and why? |
No idea when it was implemented, although I'm sure I could look.
I am fairly confident the current algorithm is to strip whitespace up to the first text of the first line and then insert to all remaining lines padding to match the current cursor position. We can certainly eliminate, all smarts and just do copy and paste of the text, which is certainly preferable in the copying line scenario, as I mentioned above. I'm not sure it's preferable with block copies. Indeed, I think the existing behaviour is likely preferable there, although you do have to know how it behaves. C# does auto formatting on paste. Heck I don't know!!!, the one good thing about simply copy and pasting text unprocessed, is you don't have to explain why it's all miss-aligned. |
So the PR that introduced it is here: Here is an issue that says it's basically broken: And another that ends up saying they like it: |
Thanks for digging up the context! In the first video, I selected the line with "Ctrl-C" (without any selection active). I do that a lot. In that case, the trouble occurs only when I paste at column 0. For the second video, the weird thing is how absolutely none of the column positions do anything useful - especially column 0. If I select some lines and paste them at column zero I expect the lines to be inserted unchanged, without any attempt at being smart. I note this comment, which said the feature should have been off by default or in preview: #9875 (comment) As an aside: I don't know much about copy-and-paste logic, but it seems pressing Ctrl-C without any selection active (which I do in the first) must create a logically different selection to selecting the line then Ctrl-C (which I do in the second). This also shows in VS Code, where a line selection initiated with Ctrl-C ignores the column on paste. Anyway I vote for turning this feature off by default. It's always felt broken. // cc @saul |
@KevinRansom and I talked and we agreed to put this pasting feature back into preview |
No description provided. |
Shall we just go ahead and disable it by default? fsharp/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs Lines 93 to 97 in b7f38ec
|
Yes, that is fine |
Disabling it here (+ Added an 'Experimental' suffix to it, as we do with CodeLens): #12454 |
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
This is similar to https://developercommunity2.visualstudio.com/t/Problem-with-indentation-in-F/719085?entry=problem&ref=native&refTime=1630938135591&refUserId=a2d84250-89b4-6645-9bad-35b10b01efbb but that is marked closed, and this is in the latest daily's
Because F# is a indentation oriented language, this is not a minor formatting issue but a major issue that causes errors that must be manually fixed, and there is no adequate Ctl-K-D to fix it all up for you.
Original Comments
Feedback Bot on 9/7/2021, 00:27 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: