From 121c2a16ef1697f3a7e9e8052226e622cf973d8a Mon Sep 17 00:00:00 2001 From: sgao Date: Fri, 18 Mar 2022 15:15:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9D=87=EF=B8=8F=20trying=20to=20fix=20co?= =?UTF-8?q?lor=20gets=20reset=20on=20open=20through=20remote/local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 ++++++- src/configuration/read-configuration.ts | 4 ++++ src/configuration/update-configuration.ts | 21 ++++++++++++++++++--- src/models/enums.ts | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 25cc74a..37fd021 100644 --- a/package.json +++ b/package.json @@ -347,6 +347,11 @@ "default": "", "description": "The Peacock color that will be applied to remote workspaces." }, + "peacock.sameRemoteLocalColor": { + "type": "boolean", + "default": false, + "description": "set same local color on setting remote color" + }, "peacock.showColorInStatusBar": { "type": "boolean", "default": true, @@ -440,4 +445,4 @@ "pre-commit": "npm run pretty" } } -} +} \ No newline at end of file diff --git a/src/configuration/read-configuration.ts b/src/configuration/read-configuration.ts index ec0d160..d469c75 100644 --- a/src/configuration/read-configuration.ts +++ b/src/configuration/read-configuration.ts @@ -225,6 +225,10 @@ export function getSurpriseMeOnStartup() { return readConfiguration(StandardSettings.SurpriseMeOnStartup, false); } +export function getSameRemoteLocalColor() { + return readConfiguration(StandardSettings.SameRemoteLocalColor, false); +} + export function getAffectedElements() { return { activityBar: readConfiguration(AffectedSettings.ActivityBar) || false, diff --git a/src/configuration/update-configuration.ts b/src/configuration/update-configuration.ts index 8a20a10..994002e 100644 --- a/src/configuration/update-configuration.ts +++ b/src/configuration/update-configuration.ts @@ -13,7 +13,7 @@ import { isObjectEmpty, } from '../models'; import { Logger } from '../logging'; -import { getFavoriteColors, getColorCustomizationConfigFromWorkspace } from './read-configuration'; +import { getFavoriteColors, getColorCustomizationConfigFromWorkspace,getSameRemoteLocalColor } from './read-configuration'; import { LiveShareSettings } from '../live-share'; export async function updateGlobalConfiguration(setting: AllSettings, value?: any) { @@ -120,16 +120,31 @@ export async function updatePeacockRemoteColorInUserSettings(color: string | und const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; return await config.update(section, color, ConfigurationTarget.Global); } - -export async function updatePeacockColor(color: string | undefined) { +export async function updatePeacockColorOnly(color: string | undefined ) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.Color}`; return await config.update(section, color, ConfigurationTarget.Workspace); +} +export async function updatePeacockRemoteColorOnly(color: string | undefined) { + const config = vscode.workspace.getConfiguration(); + const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; + return await config.update(section, color, ConfigurationTarget.Workspace); } +export async function updatePeacockColor(color: string | undefined ) { + const config = vscode.workspace.getConfiguration(); + const section = `${extensionShortName}.${StandardSettings.Color}`; + if (getSameRemoteLocalColor()){ + await updatePeacockRemoteColorOnly(color); + } + return await config.update(section, color, ConfigurationTarget.Workspace); +} export async function updatePeacockRemoteColor(color: string | undefined) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; + if (getSameRemoteLocalColor()){ + await updatePeacockColorOnly(color); + } return await config.update(section, color, ConfigurationTarget.Workspace); } diff --git a/src/models/enums.ts b/src/models/enums.ts index dc6ca7c..122fe82 100644 --- a/src/models/enums.ts +++ b/src/models/enums.ts @@ -10,6 +10,7 @@ export enum StandardSettings { KeepForegroundColor = 'keepForegroundColor', LightForegroundColor = 'lightForegroundColor', RemoteColor = 'remoteColor', + SameRemoteLocalColor = 'sameRemoteLocalColor', ShowColorInStatusBar = 'showColorInStatusBar', SurpriseMeFromFavoritesOnly = 'surpriseMeFromFavoritesOnly', SurpriseMeOnStartup = 'surpriseMeOnStartup', From 86a4331be8919a4a9c8c740c1e64c383c966ff51 Mon Sep 17 00:00:00 2001 From: sgao Date: Fri, 18 Mar 2022 15:16:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configuration/update-configuration.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/configuration/update-configuration.ts b/src/configuration/update-configuration.ts index 994002e..8b39e4d 100644 --- a/src/configuration/update-configuration.ts +++ b/src/configuration/update-configuration.ts @@ -13,7 +13,11 @@ import { isObjectEmpty, } from '../models'; import { Logger } from '../logging'; -import { getFavoriteColors, getColorCustomizationConfigFromWorkspace,getSameRemoteLocalColor } from './read-configuration'; +import { + getFavoriteColors, + getColorCustomizationConfigFromWorkspace, + getSameRemoteLocalColor, +} from './read-configuration'; import { LiveShareSettings } from '../live-share'; export async function updateGlobalConfiguration(setting: AllSettings, value?: any) { @@ -120,29 +124,29 @@ export async function updatePeacockRemoteColorInUserSettings(color: string | und const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; return await config.update(section, color, ConfigurationTarget.Global); } -export async function updatePeacockColorOnly(color: string | undefined ) { +export async function updatePeacockColorOnly(color: string | undefined) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.Color}`; return await config.update(section, color, ConfigurationTarget.Workspace); -} +} export async function updatePeacockRemoteColorOnly(color: string | undefined) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; return await config.update(section, color, ConfigurationTarget.Workspace); } -export async function updatePeacockColor(color: string | undefined ) { +export async function updatePeacockColor(color: string | undefined) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.Color}`; - if (getSameRemoteLocalColor()){ + if (getSameRemoteLocalColor()) { await updatePeacockRemoteColorOnly(color); } return await config.update(section, color, ConfigurationTarget.Workspace); -} +} export async function updatePeacockRemoteColor(color: string | undefined) { const config = vscode.workspace.getConfiguration(); const section = `${extensionShortName}.${StandardSettings.RemoteColor}`; - if (getSameRemoteLocalColor()){ + if (getSameRemoteLocalColor()) { await updatePeacockColorOnly(color); } return await config.update(section, color, ConfigurationTarget.Workspace);