Browse Source

Fixes #239 - closeOnFocusOut was backwards

main
Eric Amodio 7 years ago
parent
commit
8fc8f79462
6 changed files with 81 additions and 24 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +8
    -2
      src/configuration.ts
  3. +35
    -21
      src/extension.ts
  4. +1
    -1
      src/quickPicks/common.ts
  5. +1
    -0
      src/system.ts
  6. +35
    -0
      src/system/version.ts

+ 1
- 0
CHANGELOG.md View File

@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Improves startup performance and reduces package size
### Fixed
- Fixes [#239](https://github.com/eamodio/vscode-gitlens/issues/239) - `gitlens.advanced.quickPick.closeOnFocusOut` setting should be reversed
- Fixes [#208](https://github.com/eamodio/vscode-gitlens/issues/208) - Gitlens doesn't work over UNC
## [7.1.0] - 2017-12-22

+ 8
- 2
src/configuration.ts View File

@ -526,8 +526,10 @@ export class Configuration {
affectsConfiguration: (section: string, resource?: Uri) => false
};
get<T>(section?: string, resource?: Uri | null) {
return workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section)!;
get<T>(section?: string, resource?: Uri | null, defaultValue?: T) {
return defaultValue === undefined
? workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section)!
: workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).get<T>(section === undefined ? ExtensionKey : section, defaultValue)!;
}
changed(e: ConfigurationChangeEvent, section: string, resource?: Uri | null) {
@ -538,6 +540,10 @@ export class Configuration {
return e === this.initializingChangeEvent;
}
inspect(section?: string, resource?: Uri | null) {
return workspace.getConfiguration(section === undefined ? undefined : ExtensionKey, resource!).inspect(section === undefined ? ExtensionKey : section);
}
name<K extends keyof IConfig>(name: K) {
return Functions.propOf(emptyConfig, name);
}

+ 35
- 21
src/extension.ts View File

@ -1,5 +1,5 @@
'use strict';
import { Objects } from './system';
import { Objects, Versions } from './system';
import { ConfigurationTarget, ExtensionContext, extensions, languages, window, workspace } from 'vscode';
import { AnnotationController } from './annotations/annotationController';
import { configuration, Configuration, IConfig } from './configuration';
@ -100,37 +100,51 @@ export async function activate(context: ExtensionContext) {
// this method is called when your extension is deactivated
export function deactivate() { }
const migration = {
major: 6,
minor: 1,
patch: 2
};
async function migrateSettings(context: ExtensionContext, previousVersion: string | undefined) {
if (previousVersion === undefined) return;
const [major, minor, patch] = previousVersion.split('.');
if (parseInt(major, 10) >= migration.major && parseInt(minor, 10) >= migration.minor && parseInt(patch, 10) >= migration.patch) return;
const previous = Versions.fromString(previousVersion);
try {
const section = configuration.name('advanced')('messages').value;
const messages: { [key: string]: boolean } = configuration.get(section);
if (Versions.compare(previous, Versions.from(6, 1, 2)) !== 1) {
try {
const section = configuration.name('advanced')('messages').value;
const messages: { [key: string]: boolean } = configuration.get(section);
let migrated = false;
let migrated = false;
for (const m of Objects.values(SuppressedMessages)) {
const suppressed = context.globalState.get<boolean>(m);
if (suppressed === undefined) continue;
for (const m of Objects.values(SuppressedMessages)) {
const suppressed = context.globalState.get<boolean>(m);
if (suppressed === undefined) continue;
migrated = true;
messages[m] = suppressed;
migrated = true;
messages[m] = suppressed;
context.globalState.update(m, undefined);
}
context.globalState.update(m, undefined);
}
if (!migrated) return;
if (!migrated) return;
await configuration.update(section, messages, ConfigurationTarget.Global);
await configuration.update(section, messages, ConfigurationTarget.Global);
}
catch (ex) {
Logger.error(ex, 'migrateSettings - messages');
}
}
if (Versions.compare(previous, Versions.from(7, 1, 0)) !== 1) {
// https://github.com/eamodio/vscode-gitlens/issues/239
const section = configuration.name('advanced')('quickPick')('closeOnFocusOut').value;
const inspection = configuration.inspect(section);
if (inspection !== undefined) {
if (inspection.globalValue !== undefined) {
await configuration.update(section, !inspection.globalValue, ConfigurationTarget.Global);
}
else if (inspection.workspaceFolderValue !== undefined) {
await configuration.update(section, !inspection.workspaceFolderValue, ConfigurationTarget.WorkspaceFolder);
}
}
}
}
catch (ex) {
Logger.error(ex, 'migrateSettings');

+ 1
- 1
src/quickPicks/common.ts View File

@ -10,7 +10,7 @@ import { Keyboard, KeyboardScope, KeyMapping, Keys } from '../keyboard';
import { ResultsExplorer } from '../views/resultsExplorer';
export function getQuickPickIgnoreFocusOut() {
return configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value);
return !configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value);
}
export function showQuickPickProgress(message: string, mapping?: KeyMapping): CancellationTokenSource {

+ 1
- 0
src/system.ts View File

@ -14,3 +14,4 @@ export * from './system/iterable';
export * from './system/object';
export * from './system/searchTree';
export * from './system/string';
export * from './system/version';

+ 35
- 0
src/system/version.ts View File

@ -0,0 +1,35 @@
'use strict';
export namespace Versions {
export interface Version {
major: number;
minor: number;
patch: number;
}
export function compare(v1: Version, v2: Version): number {
if (v1.major > v2.major) return 1;
if (v1.major < v2.major) return -1;
if (v1.minor > v2.minor) return 1;
if (v1.minor < v2.minor) return -1;
if (v1.patch > v2.patch) return 1;
if (v1.patch < v2.patch) return -1;
return 0;
}
export function from(major: string | number, minor: string | number, patch: string | number): Version {
return {
major: typeof major === 'string' ? parseInt(major, 10) : major,
minor: typeof minor === 'string' ? parseInt(minor, 10) : minor,
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch
};
}
export function fromString(version: string): Version {
const [major, minor, patch] = version.split('.');
return from(major, minor, patch);
}
}

Loading…
Cancel
Save