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

Migration occurs when colors are in user settings but not in workspace. #263

Closed
kbd opened this issue Aug 20, 2019 · 7 comments · Fixed by #265

Comments

@kbd
Copy link

@kbd kbd commented Aug 20, 2019

  • OS: Mac 10.14.5
  • VS Code: 1.37.1
  • Peacock Version: 3.1.1

Peacock is creating new workspace settings when surpriseMeOnStartup is false.

$ rg peacock ~/Library/Application\ Support/Code/User/settings.json
95:    "peacock.surpriseMeOnStartup": false,
96:    "peacock.affectStatusBar": false,
97:    "peacock.affectActivityBar": false,
98:    "peacock.affectAccentBorders": false,
99:    "peacock.affectTabActiveBorder": true,
100:    "peacock.favoriteColors": [
$ ls -a
./  ../
$ code .
$ ls -a
./  ../  .vscode/
$ bat --style=header,numbers .vscode/*
     File: .vscode/settings.json
   1 {
   2     "peacock.color": "#777",
   3     "workbench.colorCustomizations": {
   4         "titleBar.activeBackground": "#777777",
   5         "titleBar.inactiveBackground": "#77777799",
   6         "titleBar.activeForeground": "#e7e7e7",
   7         "titleBar.inactiveForeground": "#e7e7e799",
   8         "tab.activeBorder": "#909090"
   9     }
  10 }

With Peacock disabled:

$ ls -a
./  ../
$ code .
$ ls -a
./  ../
@johnpapa

This comment has been minimized.

Copy link
Owner

@johnpapa johnpapa commented Aug 21, 2019

I'm trying to understand what you are showing me above. I think you are showing first the user settings (if so, it is clearer to just type the setting value).

Then I think you are showing the values in the workspace settings. I assume those are the workspace settings after using peacock 3.1.1 --- but what was in that file before?

Also, can you check the output panel for what peacock logged, and post that here please?

This will help me better reproduce it. I just opened a new project with no workspace, using 3.1.1, and it did not create a settings.json for me. So I need some more details. Thanks in advance.

@johnpapa

This comment has been minimized.

Copy link
Owner

@johnpapa johnpapa commented Aug 21, 2019

I have a theory .... try this:

  1. open the project where you saw this behavior.
  2. remove the peacock colors and delete the settings.json file
  3. Then reload vscode (reload window). This will force all extensions to reload.

If the settings.json file doesn't come back after doing this, then my theory is that the project where you saw this behavior may have been set to a color in a previous version of peacock. Peacock v2 used a memento (think of it as a hidden setting) to store the color. This was undesirable for many reasons (hard to see it, hard to track it, and users knew nothing about it). it also caused unpredictable behavior. Thus I removed this in v3. But, to help migrate people from v2 to v3, if I find the memento, I migrate it to the new peacock.color and delete the memento. In your project notice the setting for peacock.color was set.

This is noted in the guide in the migration section. I would happily take suggestions or PRs for more docs, if it is not clear.

However, this may not be what you are experiencing. Another way to check this is if you can create a new folder (that has never had vs code open on it), then open vscode in it. Peacock does nothing in this case for me ... what does it do for you?

@kbd

This comment has been minimized.

Copy link
Author

@kbd kbd commented Aug 21, 2019

I think you are showing first the user settings (if so, it is clearer to just type the setting value).

Correct. I gave the grep over my vscode config to prove that I have surpriseMeOnStartup off so there's no question.

but what was in that file before?

It didn't exist. The above shell session shows:

  1. "surprise me on startup" is off
  2. I'm in an empty directory (to answer your later point, this was a freshly created directory that hadn't been opened in vscode before).
  3. I execute vscode in the directory.
  4. It creates the workspace config.

Also, can you check the output panel for what peacock logged, and post that here please?

I just ran this in a fresh directory on my home computer on Peacock 3.1.2 and it gave this output:

Peacock Mementos
  [
  {
    "name": "peacock.favoritesVersion",
    "type": "globalState",
    "value": "3.0.1"
  }
]
Migration: Applying color #777.
Peacock is in a workspace, so Peacock functionality is available.
peacock: Updating the workspace with the following color customizations
  titleBar.activeBackground = #777777
  titleBar.inactiveBackground = #77777799
  titleBar.activeForeground = #e7e7e7
  titleBar.inactiveForeground = #e7e7e799
  tab.activeBorder = #909090

peacock: Peacock is now using #777777

Just to show that it's in a fresh directory:

~P/peacock$ mkdir thisisadirectorythathasneverexistedinhistory
~P/peacock$ cd thisisadirectorythathasneverexistedinhistory
~P/peacock/thisisadirectorythathasneverexistedinhistory$ ls -a
./  ../
~P/peacock/thisisadirectorythathasneverexistedinhistory$ code .
~P/peacock/thisisadirectorythathasneverexistedinhistory$ bat --style=header .vscode/*
File: .vscode/settings.json
{
    "peacock.color": "#777",
    "workbench.colorCustomizations": {
        "titleBar.activeBackground": "#777777",
        "titleBar.inactiveBackground": "#77777799",
        "titleBar.activeForeground": "#e7e7e7",
        "titleBar.inactiveForeground": "#e7e7e799",
        "tab.activeBorder": "#909090"
    }
}

Again, here are my full vscode settings. At some point I created these workspace settings:

    "workbench.colorCustomizations": {
        "editor.selectionBackground": "#888",
        "editor.selectionHighlightBackground": "#555",
        "editor.findMatchHighlightBackground": "#2cdd1c65",
        "titleBar.activeBackground": "#777",
        "titleBar.inactiveBackground": "#696969",
        "editorIndentGuide.activeBackground": "#888"
    },

When I remove titleBar.activeBackground and titleBar.inactiveBackground and open vscode in a new directory, Peacock doesn't cause the workspace settings.json to be created. So, Peacock seems to look at the currently set settings, sees that those two are set, goes "those are settings I care about, I should write the workspace config", even though those are set in my global config.

It would be good if you could tell "is the current color different from the color set in the user's global config?" Is there any way in the vscode API to distinguish what's set globally vs what's set in the current workspace?

@johnpapa

This comment has been minimized.

Copy link
Owner

@johnpapa johnpapa commented Aug 21, 2019

At some point I created these workspace settings:

    "workbench.colorCustomizations": {
        "editor.selectionBackground": "#888",
        "editor.selectionHighlightBackground": "#555",
        "editor.findMatchHighlightBackground": "#2cdd1c65",
        "titleBar.activeBackground": "#777",
        "titleBar.inactiveBackground": "#696969",
        "editorIndentGuide.activeBackground": "#888"
    },

That was the key information I needed! Thanks! So you have a user settings.json color set. VS Code's API merges default settings and user settings and workspace settings together. So when peacock was checking if it should migrate, it saw you had a color set, and migrated for you.

What the code should be doing is checking if you have a color in the workspace only (as you point out here)

It would be good if you could tell "is the current color different from the color set in the user's global config?" Is there any way in the vscode API to distinguish what's set globally vs what's set in the current workspace?

Yes, there is. It's not as easy as "give me the color" but I have the logic and I am currently testing it to make it sure it works and there are no regressions elsewhere.

Thank you for elaborating

@johnpapa johnpapa changed the title Peacock creates new workspace settings.json when surpriseMeOnStartup = false Migration occurs when colors are in user settings but not in workspace. Aug 21, 2019
@johnpapa

This comment has been minimized.

Copy link
Owner

@johnpapa johnpapa commented Aug 21, 2019

Fix is being testing in CI and pending in v3.1.4

@kbd

This comment has been minimized.

Copy link
Author

@kbd kbd commented Aug 21, 2019

At some point I created these workspace settings:

Just to clarify, I mistyped "workspace" when I meant "workbench".

Fix is being testing in CI and pending in v3.1.4

Just confirmed that on 3.1.4 no workspace settings.json is written in a fresh directory. Thanks for fix!

@johnpapa

This comment has been minimized.

Copy link
Owner

@johnpapa johnpapa commented Aug 21, 2019

thanks for verifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.