multipass icon indicating copy to clipboard operation
multipass copied to clipboard

Integration with Windows Terminal heavily modifies its settings

Open Birdie0 opened this issue 5 years ago • 7 comments

Describe the bug Integration changes Windows Terminal settings file in ways its not supposed to:

  • spaces converted to tabs
  • added space between key and colon
  • all keys got sorted by name
  • blank lines got removed

To Reproduce How, and what happened?

  1. Make sure there's no multipass profile in settings.json
  2. Run multipass
  3. Open Windows Terminal settings.json

Expected behavior Integration to just add multipass profile without modifying anything else.

Additional info

  • OS: Windows 10 Pro x64 Build 18363
  • multipass version multipass 1.3.0+win multipassd 1.3.0+win
  • multipass info --all Name: ubuntu-lts State: Running IPv4: 172.18.48.150 Release: Ubuntu 18.04.4 LTS Image hash: 3b2e3aaaebf2 (Ubuntu 18.04 LTS) Load: 0.08 0.02 0.01 Disk usage: 5.3G out of 9.5G Memory usage: 3.0G out of 3.9G

Additional context The problem is this behaviour is unlikable, pretty sure other users don't want their settings file setup got modified like that.

Birdie0 avatar Jun 10 '20 07:06 Birdie0

Hi @Birdie0, we're using the same JSON library Windows Terminal is using (open-source-parsers/jsoncpp), and while we may be able to configure the output somewhat, it will always rewrite it completely, as we can't just treat the file as text and dump some lines in between some others. We always read in the whole file, parse it, modify and output the whole of it. That's the only way to ensure it's valid JSON, and that it has valid schema.

It's unfortunate that JSON is the current "user interface" to Windows Terminal settings, and I know they're working on proper UI for it. We also hope there will be API available to better integrate with it (rather than modifying files).

Saviq avatar Jun 10 '20 09:06 Saviq

Hi, I would just like to add that this integration can be disabled with multipass set client.apps.windows-terminal.profiles=none (see the docs). Note that this will again edit the settings file to disable the profile, if it is still there and enabled. From then on, multipass will only modify the file if it finds its profile (only one for now) there and enabled. Conversely, when the setting is enabled, multipass will only edit the file if it finds its profile missing or disabled.

ricab avatar Jun 15 '20 10:06 ricab

Thanks for the suggestion, @ricab ! I guess I'll be using it for now.

Birdie0 avatar Jun 16 '20 16:06 Birdie0

Hi, I just want to add that this causes additional problem for me. I added custom keybindings in my settings.json file, that for some reason make it impossible to be validated according to its schema, even though they work and are correct according to WT documentation. This causes multipass to show error on every command.

I reported this issue to WT team here: https://github.com/microsoft/terminal/issues/6827

After running multipass set client.apps.windows-terminal.profiles=none the issue disappeared.

Forinil avatar Jul 08 '20 08:07 Forinil

FWIW @Forinil's problem was a BOM in the file, I filed #1634 to track this. In the interim, you'll have to ensure the file is UTF-8 without a BOM.

Saviq avatar Jul 08 '20 10:07 Saviq

A while ago Windows Terminal added support of JSON fragment extensions that allows to add profiles dynamically without modifying settings file directly.

Birdie0 avatar Jul 13 '23 10:07 Birdie0

Thanks for pointing that out @Birdie0. I am afraid we're a little too busy to revise the implementation now. Maybe some time in the future.

ricab avatar Jul 13 '23 11:07 ricab