Skip to content

Commit

Permalink
Empty config is sent to the server after merge of configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
  • Loading branch information
vrubezhny committed Nov 20, 2019
1 parent a31ecf1 commit 07c6155
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,23 @@ export function createMiddleware(getClient: () => LanguageClient): IntelephenseM
return Array.from(excludeSet);
}

function mergeResult (r: any, params: ConfigurationParams) {
if(Array.isArray(r)) {
r.forEach((v, i) => {
if(v && v.files && v.files.associations) {
v.files.associations = mergeAssociations(v.files.associations);
}
if(v && v.files && v.files.exclude) {
v.files.exclude = mergeExclude(v.files.exclude, params.items[i].scopeUri);
}
if(v && v.telemetry === null) {
v.telemetry.enabled = workspace.getConfiguration('telemetry').get('enableTelemetry');
}
});
}
return r;
}

let lastCompletionWasPhp = true;
let middleware = <IntelephenseMiddleware>{
workspace: {
Expand All @@ -311,25 +328,10 @@ export function createMiddleware(getClient: () => LanguageClient): IntelephenseM

let result = next(params, token);
if(!isThenable(result)) {
result = Promise.resolve(result);
return mergeResult(result, params);
}

return (<Thenable<any>>result).then(r => {
if(Array.isArray(r)) {
r.forEach((v, i) => {
if(v && v.files && v.files.associations) {
v.files.associations = mergeAssociations(v.files.associations);
}
if(v && v.files && v.files.exclude) {
v.files.exclude = mergeExclude(v.files.exclude, params.items[i].scopeUri);
}
if(v && v.telemetry === null) {
v.telemetry.enabled = workspace.getConfiguration('telemetry').get('enableTelemetry');
}
});
}
return r;
});
return (<Thenable<any>>result).then(r => mergeResult(r, params));
}
},

Expand Down

0 comments on commit 07c6155

Please sign in to comment.