Skip to content

Commit 71aace5

Browse files
committed
Fixes #336 - stops adding suppressed message defaults
1 parent 0ed6b79 commit 71aace5

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1010

1111
### Fixed
1212
- Fixes [#345](https://github.com/eamodio/vscode-gitlens/issues/345) - Custom date formats don't work in the GitLens view
13+
- Fixes [#336](https://github.com/eamodio/vscode-gitlens/issues/336) - Default Settings Get Added Automatically
1314
- Fixes issue where username and/or password in a remote urls could be shown
1415

1516
## [8.2.1] - 2018-04-11

src/messages.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ export class Messages {
3232
}
3333

3434
static async showKeyBindingsInfoMessage(): Promise<MessageItem | undefined> {
35-
const section = configuration.name('advanced')('messages').value;
36-
const messages: { [key: string]: boolean } = configuration.get<{}>(section);
37-
38-
if (messages[SuppressedMessages.ShowKeyBindingsNotice]) return undefined;
35+
if (Container.config.advanced.messages.suppressShowKeyBindingsNotice) return undefined;
3936

4037
if (Container.config.keymap !== KeyMap.Alternate) {
41-
messages[SuppressedMessages.ShowKeyBindingsNotice] = true;
42-
await configuration.update(section, messages, ConfigurationTarget.Global);
38+
await this.suppressedMessage(SuppressedMessages.ShowKeyBindingsNotice);
4339

4440
return undefined;
4541
}
@@ -115,16 +111,27 @@ export class Messages {
115111

116112
if (dontShowAgain === null || result === dontShowAgain) {
117113
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested`);
118-
119-
const section = configuration.name('advanced')('messages').value;
120-
const messages: { [key: string]: boolean } = configuration.get<{}>(section);
121-
messages[suppressionKey] = true;
122-
await configuration.update(section, messages, ConfigurationTarget.Global);
114+
await this.suppressedMessage(suppressionKey);
123115

124116
if (result === dontShowAgain) return undefined;
125117
}
126118

127119
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) returned ${result ? result.title : result}`);
128120
return result;
129121
}
122+
123+
private static suppressedMessage(suppressionKey: SuppressedMessages) {
124+
const section = configuration.name('advanced')('messages').value;
125+
const messages: { [key: string]: boolean | undefined } = configuration.get<{}>(section);
126+
127+
messages[suppressionKey] = true;
128+
129+
for (const [key, value] of Object.entries(messages)) {
130+
if (value !== true) {
131+
messages[key] = undefined;
132+
}
133+
}
134+
135+
return configuration.update(section, messages, ConfigurationTarget.Global);
136+
}
130137
}

0 commit comments

Comments
 (0)