import * as fs from 'fs' ; import * as path from 'path' ; import { Editor } from './editor' ; import { Editors } from './editors' ; import { Code } from './code' ; import { QuickAccess } from './quickaccess' ; export class SettingsEditor { constructor ( private code , private userDataPath , private editors , private editor , private quickaccess ) { } async addUserSetting ( setting , value ) { await this . openSettings ( ) ; await this . editor . waitForEditorFocus ( 'settings.json' , 1 ) ; await this . code . dispatchKeybinding ( 'right' ) ; await this . editor . waitForTypeInEditor ( 'settings.json' , `"${ setting }": ${ value },` ) ; await this . editors . saveOpenedFile ( ) ; } async clearUserSettings ( ) { const settingsPath = path . join ( this . userDataPath , 'User' , 'settings.json' ) ; await new Promise < void > ( ( c , e ) => fs . writeFile ( settingsPath , '{\n}' , 'utf8' , err => err ? e ( err ) : c ( ) ) ) ; await this . openSettings ( ) ; await this . editor . waitForEditorContents ( 'settings.json' , c => c === '{}' ) ; } private async openSettings ( ) { await this . quickaccess . runCommand ( 'workbench.action.openSettingsJson' ) ; } }