11import * as vscode from "vscode" ;
22import DeepCode from "../../../interfaces/DeepCodeInterfaces" ;
3+ import { errorsLogs } from "../../messages/errorsServerLogMessages" ;
34
45class DeepCodeSettingsWatcher implements DeepCode . DeepCodeWatcherInterface {
56
6- private async onChangeConfiguration ( extension : DeepCode . ExtensionInterface ) : Promise < void > {
7+ private async onChangeConfiguration ( extension : DeepCode . ExtensionInterface , key : string ) : Promise < void > {
78 const extensionConfig = vscode . workspace . getConfiguration ( 'deepcode' ) ;
89 // @ts -ignore */}
910 const url : string = extensionConfig . get ( 'url' ) ;
@@ -18,13 +19,21 @@ class DeepCodeSettingsWatcher implements DeepCode.DeepCodeWatcherInterface {
1819
1920 public activate ( extension : DeepCode . ExtensionInterface ) : void {
2021 vscode . workspace . onDidChangeConfiguration (
21- ( event : vscode . ConfigurationChangeEvent ) : void => {
22- if (
23- event . affectsConfiguration ( 'deepcode.url' ) ||
24- event . affectsConfiguration ( 'deepcode.token' ) ||
25- event . affectsConfiguration ( 'deepcode.uploadApproved' )
26- ) {
27- this . onChangeConfiguration ( extension ) ;
22+ async ( event : vscode . ConfigurationChangeEvent ) : Promise < void > => {
23+ const change = [
24+ 'deepcode.url' , 'deepcode.token' , 'deepcode.uploadApproved'
25+ ] . find ( config => event . affectsConfiguration ( config ) ) ;
26+ if ( change ) {
27+ try {
28+ await this . onChangeConfiguration ( extension , change ) ;
29+ } catch ( error ) {
30+ await extension . processError ( error , {
31+ message : errorsLogs . configWatcher ,
32+ data : {
33+ configurationKey : change ,
34+ }
35+ } )
36+ }
2837 }
2938 }
3039 ) ;
0 commit comments