Skip to content
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

Reduce automated language setting of untitled file on paste #90492

Closed
akbyrd opened this issue Feb 11, 2020 · 7 comments
Closed

Reduce automated language setting of untitled file on paste #90492

akbyrd opened this issue Feb 11, 2020 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Milestone

Comments

@akbyrd
Copy link
Contributor

akbyrd commented Feb 11, 2020

The new feature that automatically sets the language of an untitled editor is blowing up my language setting even after I set it explicitly.

Repro
Open a new file
Explicitly set it to plain text
Paste text from another editor
Notice it changes the language mode

I use plain text editors constantly and this is frustrating.

@vscodebot
Copy link

vscodebot bot commented Feb 11, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@gjsjohnmurray
Copy link
Contributor

Repro
Open a new file
Explicitly set it to plain text
Paste text from another editor
Notice it changes the language mode

@akbyrd I'm not clear why you need to set language mode explicitly to plain text right after opening a new file. Perhaps you have set files.defaultLanguage

But assuming that step is necessary, can you simply defer doing it until after pasting?

I'm not disagreeing with your request for this new behaviour to be switchable. Just trying to understand if you can work around it without having an extra step to do.

@akbyrd
Copy link
Contributor Author

akbyrd commented Feb 11, 2020

I don't have to set the language to plain text right after opening. I'm using that step to demonstrate that the new feature will alter something I explicitly set, which it should never do.

My untitled files already default to plain text because
"files.defaultLanguage": ""

Perhaps this alternate repro will demonstrate the problem more clearly:

  • Open a new file (defaults to plain text)
  • Paste text from another editor
  • Notice it changes the language mode (expected, fine)
  • Set language back to plain text
  • Paste again
  • Notice it changes the language mode again (problem!)
  • Set language back to plain text
  • Repeat ad nauseam

@bpasero
Copy link
Member

bpasero commented Feb 12, 2020

The current heuristic in insiders (changed slightly from stable) is as follows:

  • if the language mode is not plain-text, we ignore the mode from the paste (same as stable)
  • if you paste anywhere outside of line 1, column 1, we ignore the mode too assuming that you have already worked with the untitled file (this is new from stable)

I think the only solution here is to provide a setting because I find it rather weird that configuring the language mode to "plain text" if it is already "plain text" should have any impact?

Curious if insiders improves this situation for you given the change we did. You can give our preview releases a try from: https://code.visualstudio.com/insiders/

@bpasero bpasero added the info-needed Issue requires more information from poster label Feb 12, 2020
@bpasero
Copy link
Member

bpasero commented Feb 12, 2020

Oh sorry, I just found a bug in insiders (fixed via 7e0133d). To see the behaviour I describe in action you need to paste into anywhere that is not line 1 and not column 1. The change I pushed makes this easier to not apply the mode unless you truly paste into line 1 and column 1.

@bpasero bpasero changed the title Untitled editor language changes on paste after I explicitly set the language Option to disable setting language of untitled file on paste Feb 12, 2020
@akbyrd
Copy link
Contributor Author

akbyrd commented Feb 12, 2020

How does this work when I select all and paste? This is something I frequently do and I assume that counts as pasting into 1:1. The heuristic fails here.

I find it rather weird that configuring the language mode to "plain text" if it is already "plain text" should have any impact?

I don't follow what you mean here. In my second repro above I only demonstrate setting to plain text from some other language that was automatically set when pasting. At no point do I set it to plain text while it is already plain text.

I think this issue should be separate from the other that you closed. This issue is a bug. You can't just run around changing the settings I want. A heuristic simply isn't enough. There's a difference between "the editor tried to automatically infer what I want" and "I explicitly set this thing". It's fine to override the former, but not the latter. You need to track "did the user explicitly set a language?" and disable the heuristic.

You can introduce an option to disable it entirely (and in my case that happens to be good enough) but that's a workaround for UX that absolutely should not exist.

@bpasero bpasero added feature-request Request for new features or functionality workbench-editors Managing of editor widgets in workbench window and removed info-needed Issue requires more information from poster labels Feb 13, 2020
@bpasero bpasero added this to the February 2020 milestone Feb 13, 2020
@bpasero
Copy link
Member

bpasero commented Feb 13, 2020

I pushed a change that will disable this feature of setting the mode automatically upon paste in more cases.

Verification:

  • you picked "plain text" on an untitled file (even if it is already "plain text") - this is now a hint to the editor that the mode was chosen by the user and should not be changed
  • this is persisted across restarts - if you have an untitled editor open and you once changed the mode explicitly, we remember that and will not change the mode on paste ever
  • you configure "files.defaultLanguage": "plaintext" - this is basically now a way to disable this feature for good

@bpasero bpasero added the verification-needed Verification of issue is requested label Feb 13, 2020
@bpasero bpasero changed the title Option to disable setting language of untitled file on paste Reduce automated language setting of untitled file on paste Feb 21, 2020
@connor4312 connor4312 added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Feb 26, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality verified Verification succeeded workbench-editors Managing of editor widgets in workbench window
Projects
None yet
Development

No branches or pull requests

5 participants