Przeglądaj źródła

Fixes issue with saving settings with default values

main
Eric Amodio 6 lat temu
rodzic
commit
28f5eb66a6
5 zmienionych plików z 43 dodań i 46 usunięć
  1. +1
    -0
      CHANGELOG.md
  2. +17
    -13
      src/configuration.ts
  3. +7
    -16
      src/views/gitExplorer.ts
  4. +16
    -10
      src/views/historyExplorer.ts
  5. +2
    -7
      src/views/resultsExplorer.ts

+ 1
- 0
CHANGELOG.md Wyświetl plik

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#444](https://github.com/eamodio/vscode-gitlens/issues/444) - GitLens custom viewlet icon slightly larger than standard
- Fixes [#437](https://github.com/eamodio/vscode-gitlens/issues/437) - Remove --first-parent from git commands to show file history from merged in repositories
- Fixes issue where GitLens saves a couple settings with default values into user settings (rather than just removing the setting)
## [8.5.0] - 2018-07-16
### Added

+ 17
- 13
src/configuration.ts Wyświetl plik

@ -256,22 +256,26 @@ export class Configuration {
async updateEffective(section: string, value: any, resource: Uri | null = null) {
const inspect = await configuration.inspect(section, resource)!;
if (inspect.workspaceFolderValue !== undefined) {
if (inspect.workspaceFolderValue === value) return;
await configuration.update(section, value, ConfigurationTarget.WorkspaceFolder, resource);
if (value === inspect.workspaceFolderValue) return;
return await configuration.update(section, value, ConfigurationTarget.WorkspaceFolder, resource);
}
else if (inspect.workspaceValue !== undefined) {
if (inspect.workspaceValue === value) return;
await configuration.update(section, value, ConfigurationTarget.Workspace);
if (inspect.workspaceValue !== undefined) {
if (value === inspect.workspaceValue) return;
return await configuration.update(section, value, ConfigurationTarget.Workspace);
}
else {
if (
inspect.globalValue === value ||
(inspect.globalValue === undefined && inspect.defaultValue === value)
) {
return;
}
await configuration.update(section, value, ConfigurationTarget.Global);
if (inspect.globalValue === value || (inspect.globalValue === undefined && value === inspect.defaultValue)) {
return;
}
return await configuration.update(
section,
value === inspect.defaultValue ? undefined : value,
ConfigurationTarget.Global
);
}
}

+ 7
- 16
src/views/gitExplorer.ts Wyświetl plik

@ -2,7 +2,6 @@
import {
commands,
ConfigurationChangeEvent,
ConfigurationTarget,
Disposable,
Event,
EventEmitter,
@ -86,12 +85,12 @@ export class GitExplorer extends Disposable implements TreeDataProvider
);
commands.registerCommand(
'gitlens.gitExplorer.setRenameFollowingOn',
() => GitExplorer.setRenameFollowing(true),
() => HistoryExplorer.setRenameFollowing(true),
this
);
commands.registerCommand(
'gitlens.gitExplorer.setRenameFollowingOff',
() => GitExplorer.setRenameFollowing(false),
() => HistoryExplorer.setRenameFollowing(false),
this
);
commands.registerCommand(
@ -428,16 +427,12 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
}
private async getHistoryNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
private getHistoryNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
return HistoryExplorer.getHistoryNode(this, editor, this._root);
}
private async setFilesLayout(layout: ExplorerFilesLayout) {
return configuration.update(
configuration.name('gitExplorer')('files')('layout').value,
layout,
ConfigurationTarget.Global
);
private setFilesLayout(layout: ExplorerFilesLayout) {
return configuration.updateEffective(configuration.name('gitExplorer')('files')('layout').value, layout);
}
private setRoot(root: ExplorerNode | undefined): boolean {
@ -451,11 +446,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider
return true;
}
private async undockHistory(switchView: boolean = true) {
Container.historyExplorer.undock(switchView);
}
static setRenameFollowing(enabled: boolean) {
configuration.updateEffective(configuration.name('advanced')('fileHistoryFollowsRenames').value, enabled);
private undockHistory(switchView: boolean = true) {
return Container.historyExplorer.undock(switchView);
}
}

+ 16
- 10
src/views/historyExplorer.ts Wyświetl plik

@ -21,7 +21,6 @@ import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Functions } from '../system';
import { RefreshNodeCommandArgs } from '../views/explorerCommands';
import { GitExplorer } from './gitExplorer';
import { Explorer, ExplorerNode, HistoryNode, MessageNode, RefreshReason } from './nodes';
export * from './nodes';
@ -47,12 +46,12 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
commands.registerCommand(
'gitlens.historyExplorer.setRenameFollowingOn',
() => GitExplorer.setRenameFollowing(true),
() => HistoryExplorer.setRenameFollowing(true),
this
);
commands.registerCommand(
'gitlens.historyExplorer.setRenameFollowingOff',
() => GitExplorer.setRenameFollowing(false),
() => HistoryExplorer.setRenameFollowing(false),
this
);
@ -158,12 +157,12 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
async dock(switchView: boolean = true, updateConfig: boolean = true) {
if (switchView) {
await Container.gitExplorer.switchTo(GitExplorerView.History);
void (await Container.gitExplorer.switchTo(GitExplorerView.History));
}
await setCommandContext(CommandContext.HistoryExplorer, false);
void (await setCommandContext(CommandContext.HistoryExplorer, false));
if (updateConfig) {
await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, false);
void (await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, false));
}
}
@ -211,12 +210,12 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
async undock(switchView: boolean = true, updateConfig: boolean = true) {
if (switchView) {
await Container.gitExplorer.switchTo(GitExplorerView.Repository);
void (await Container.gitExplorer.switchTo(GitExplorerView.Repository));
}
await setCommandContext(CommandContext.HistoryExplorer, this.config.location);
void (await setCommandContext(CommandContext.HistoryExplorer, this.config.location));
if (updateConfig) {
await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, true);
void (await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, true));
}
}
@ -227,7 +226,7 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
this._root = undefined;
}
private async getRootNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
private getRootNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
return HistoryExplorer.getHistoryNode(this, editor, this._root);
}
@ -285,4 +284,11 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
}
return new HistoryNode(gitUri, repo, explorer);
}
static setRenameFollowing(enabled: boolean) {
return configuration.updateEffective(
configuration.name('advanced')('fileHistoryFollowsRenames').value,
enabled
);
}
}

+ 2
- 7
src/views/resultsExplorer.ts Wyświetl plik

@ -2,7 +2,6 @@
import {
commands,
ConfigurationChangeEvent,
ConfigurationTarget,
Disposable,
Event,
EventEmitter,
@ -298,12 +297,8 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider
this.refresh();
}
private async setFilesLayout(layout: ExplorerFilesLayout) {
return configuration.update(
configuration.name('resultsExplorer')('files')('layout').value,
layout,
ConfigurationTarget.Global
);
private setFilesLayout(layout: ExplorerFilesLayout) {
return configuration.updateEffective(configuration.name('resultsExplorer')('files')('layout').value, layout);
}
private setKeepResults(enabled: boolean) {

Ładowanie…
Anuluj
Zapisz