Skip to content

Commit 8fc8f79

Browse files
committed
Fixes #239 - closeOnFocusOut was backwards
1 parent b01d7ab commit 8fc8f79

File tree

6 files changed

+81
-24
lines changed

6 files changed

+81
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2020
- Improves startup performance and reduces package size
2121

2222
### Fixed
23+
- Fixes [#239](https://github.com/eamodio/vscode-gitlens/issues/239) - `gitlens.advanced.quickPick.closeOnFocusOut` setting should be reversed
2324
- Fixes [#208](https://github.com/eamodio/vscode-gitlens/issues/208) - Gitlens doesn't work over UNC
2425

2526
## [7.1.0] - 2017-12-22

src/configuration.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,10 @@ export class Configuration {
526526
affectsConfiguration: (section: string, resource?: Uri) => false
527527
};
528528

529-
get<T>(section?: string, resource?: Uri | null) {
530-
return workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section)!;
529+
get<T>(section?: string, resource?: Uri | null, defaultValue?: T) {
530+
return defaultValue === undefined
531+
? workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section)!
532+
: workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section, defaultValue)!;
531533
}
532534

533535
changed(e: ConfigurationChangeEvent, section: string, resource?: Uri | null) {
@@ -538,6 +540,10 @@ export class Configuration {
538540
return e === this.initializingChangeEvent;
539541
}
540542

543+
inspect(section?: string, resource?: Uri | null) {
544+
return workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).inspect(section === undefined ? ExtensionKey : section);
545+
}
546+
541547
name<K extends keyof IConfig>(name: K) {
542548
return Functions.propOf(emptyConfig, name);
543549
}

src/extension.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
import { Objects } from './system';
2+
import { Objects, Versions } from './system';
33
import { ConfigurationTarget, ExtensionContext, extensions, languages, window, workspace } from 'vscode';
44
import { AnnotationController } from './annotations/annotationController';
55
import { configuration, Configuration, IConfig } from './configuration';
@@ -100,37 +100,51 @@ export async function activate(context: ExtensionContext) {
100100
// this method is called when your extension is deactivated
101101
export function deactivate() { }
102102

103-
const migration = {
104-
major: 6,
105-
minor: 1,
106-
patch: 2
107-
};
108-
109103
async function migrateSettings(context: ExtensionContext, previousVersion: string | undefined) {
110104
if (previousVersion === undefined) return;
111105

112-
const [major, minor, patch] = previousVersion.split('.');
113-
if (parseInt(major, 10) >= migration.major && parseInt(minor, 10) >= migration.minor && parseInt(patch, 10) >= migration.patch) return;
106+
const previous = Versions.fromString(previousVersion);
114107

115108
try {
116-
const section = configuration.name('advanced')('messages').value;
117-
const messages: { [key: string]: boolean } = configuration.get(section);
109+
if (Versions.compare(previous, Versions.from(6, 1, 2)) !== 1) {
110+
try {
111+
const section = configuration.name('advanced')('messages').value;
112+
const messages: { [key: string]: boolean } = configuration.get(section);
118113

119-
let migrated = false;
114+
let migrated = false;
120115

121-
for (const m of Objects.values(SuppressedMessages)) {
122-
const suppressed = context.globalState.get<boolean>(m);
123-
if (suppressed === undefined) continue;
116+
for (const m of Objects.values(SuppressedMessages)) {
117+
const suppressed = context.globalState.get<boolean>(m);
118+
if (suppressed === undefined) continue;
124119

125-
migrated = true;
126-
messages[m] = suppressed;
120+
migrated = true;
121+
messages[m] = suppressed;
127122

128-
context.globalState.update(m, undefined);
129-
}
123+
context.globalState.update(m, undefined);
124+
}
130125

131-
if (!migrated) return;
126+
if (!migrated) return;
132127

133-
await configuration.update(section, messages, ConfigurationTarget.Global);
128+
await configuration.update(section, messages, ConfigurationTarget.Global);
129+
}
130+
catch (ex) {
131+
Logger.error(ex, 'migrateSettings - messages');
132+
}
133+
}
134+
135+
if (Versions.compare(previous, Versions.from(7, 1, 0)) !== 1) {
136+
// https://github.com/eamodio/vscode-gitlens/issues/239
137+
const section = configuration.name('advanced')('quickPick')('closeOnFocusOut').value;
138+
const inspection = configuration.inspect(section);
139+
if (inspection !== undefined) {
140+
if (inspection.globalValue !== undefined) {
141+
await configuration.update(section, !inspection.globalValue, ConfigurationTarget.Global);
142+
}
143+
else if (inspection.workspaceFolderValue !== undefined) {
144+
await configuration.update(section, !inspection.workspaceFolderValue, ConfigurationTarget.WorkspaceFolder);
145+
}
146+
}
147+
}
134148
}
135149
catch (ex) {
136150
Logger.error(ex, 'migrateSettings');

src/quickPicks/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Keyboard, KeyboardScope, KeyMapping, Keys } from '../keyboard';
1010
import { ResultsExplorer } from '../views/resultsExplorer';
1111

1212
export function getQuickPickIgnoreFocusOut() {
13-
return configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value);
13+
return !configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value);
1414
}
1515

1616
export function showQuickPickProgress(message: string, mapping?: KeyMapping): CancellationTokenSource {

src/system.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export * from './system/iterable';
1414
export * from './system/object';
1515
export * from './system/searchTree';
1616
export * from './system/string';
17+
export * from './system/version';

src/system/version.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
export namespace Versions {
4+
export interface Version {
5+
major: number;
6+
minor: number;
7+
patch: number;
8+
}
9+
10+
export function compare(v1: Version, v2: Version): number {
11+
if (v1.major > v2.major) return 1;
12+
if (v1.major < v2.major) return -1;
13+
14+
if (v1.minor > v2.minor) return 1;
15+
if (v1.minor < v2.minor) return -1;
16+
17+
if (v1.patch > v2.patch) return 1;
18+
if (v1.patch < v2.patch) return -1;
19+
20+
return 0;
21+
}
22+
23+
export function from(major: string | number, minor: string | number, patch: string | number): Version {
24+
return {
25+
major: typeof major === 'string' ? parseInt(major, 10) : major,
26+
minor: typeof minor === 'string' ? parseInt(minor, 10) : minor,
27+
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch
28+
};
29+
}
30+
31+
export function fromString(version: string): Version {
32+
const [major, minor, patch] = version.split('.');
33+
return from(major, minor, patch);
34+
}
35+
}

0 commit comments

Comments
 (0)