Skip to content

Commit

Permalink
fix(configuration): supply resource uri when retrieving configuration…
Browse files Browse the repository at this point in the history
… to stop all the crazy warning msgs
  • Loading branch information
jpoon committed Nov 13, 2017
1 parent 1527655 commit 2e793df
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ class ConfigurationClass {
}
set disableExt(isDisabled: boolean) {
this.disableExtension = isDisabled;
vscode.workspace
.getConfiguration('vim')
.update('disableExtension', isDisabled, ConfigurationTarget.Global);
getConfiguration('vim').update('disableExtension', isDisabled, ConfigurationTarget.Global);
}

enableNeovim = true;
Expand Down Expand Up @@ -335,6 +333,15 @@ class ConfigurationClass {
cmdLineInitialColon = false;
}

function getConfiguration(section: string): vscode.WorkspaceConfiguration {
let resource: vscode.Uri | undefined = undefined;
let activeTextEditor = vscode.window.activeTextEditor;
if (activeTextEditor) {
resource = activeTextEditor.document.uri;
}
return vscode.workspace.getConfiguration(section, resource);
}

function overlapSetting(args: {
codeName: string;
default: OptionValue;
Expand All @@ -347,7 +354,7 @@ function overlapSetting(args: {
return this['_' + propertyKey];
}

let val = vscode.workspace.getConfiguration('editor').get(args.codeName, args.default);
let val = getConfiguration('editor').get(args.codeName, args.default);
if (args.codeValueMapping && val !== undefined) {
val = args.codeValueMapping[val as string];
}
Expand All @@ -368,9 +375,11 @@ function overlapSetting(args: {
codeValue = args.codeValueMapping[value];
}

await vscode.workspace
.getConfiguration('editor')
.update(args.codeName, codeValue, vscode.ConfigurationTarget.Global);
await getConfiguration('editor').update(
args.codeName,
codeValue,
vscode.ConfigurationTarget.Global
);
}, 'config');
},
enumerable: true,
Expand Down

0 comments on commit 2e793df

Please sign in to comment.