@@ -24,6 +24,7 @@ export interface Settings extends Index {
2424 editorFontSize : number ; // `editor.fontSize`
2525 themeId : string ; // `workbench.colorTheme`
2626 autoSave : 'on' | 'off' ; // `editor.autoSave`
27+ quickSuggestions : Record < 'other' | 'comments' | 'strings' , boolean > ; // `editor.quickSuggestions`
2728
2829 autoScaleInterface : boolean ; // `arduino.window.autoScale`
2930 interfaceScale : number ; // `arduino.window.zoomLevel` https://github.com/eclipse-theia/theia/issues/8751
@@ -84,6 +85,7 @@ export class SettingsService {
8485 editorFontSize ,
8586 themeId ,
8687 autoSave ,
88+ quickSuggestions ,
8789 autoScaleInterface ,
8890 interfaceScale ,
8991 // checkForUpdates,
@@ -97,6 +99,11 @@ export class SettingsService {
9799 this . preferenceService . get < number > ( 'editor.fontSize' , 12 ) ,
98100 this . preferenceService . get < string > ( 'workbench.colorTheme' , 'arduino-theme' ) ,
99101 this . preferenceService . get < 'on' | 'off' > ( 'editor.autoSave' , 'on' ) ,
102+ this . preferenceService . get < object > ( 'editor.quickSuggestion' , {
103+ 'other' : false ,
104+ 'comments' : false ,
105+ 'strings' : false
106+ } ) ,
100107 this . preferenceService . get < boolean > ( 'arduino.window.autoScale' , true ) ,
101108 this . preferenceService . get < number > ( 'arduino.window.zoomLevel' , 0 ) ,
102109 // this.preferenceService.get<string>('arduino.ide.autoUpdate', true),
@@ -113,6 +120,7 @@ export class SettingsService {
113120 editorFontSize,
114121 themeId,
115122 autoSave,
123+ quickSuggestions,
116124 autoScaleInterface,
117125 interfaceScale,
118126 // checkForUpdates,
@@ -155,10 +163,10 @@ export class SettingsService {
155163 return `Invalid sketchbook location: ${ sketchbookPath } ` ;
156164 }
157165 if ( editorFontSize <= 0 ) {
158- return ` Invalid editor font size. It must be a positive integer.` ;
166+ return ' Invalid editor font size. It must be a positive integer.' ;
159167 }
160168 if ( ! ThemeService . get ( ) . getThemes ( ) . find ( ( { id } ) => id === themeId ) ) {
161- return ` Invalid theme.` ;
169+ return ' Invalid theme.' ;
162170 }
163171 return true ;
164172 } catch ( err ) {
@@ -175,6 +183,7 @@ export class SettingsService {
175183 editorFontSize,
176184 themeId,
177185 autoSave,
186+ quickSuggestions,
178187 autoScaleInterface,
179188 interfaceScale,
180189 // checkForUpdates,
@@ -199,6 +208,7 @@ export class SettingsService {
199208 this . preferenceService . set ( 'editor.fontSize' , editorFontSize , PreferenceScope . User ) ,
200209 this . preferenceService . set ( 'workbench.colorTheme' , themeId , PreferenceScope . User ) ,
201210 this . preferenceService . set ( 'editor.autoSave' , autoSave , PreferenceScope . User ) ,
211+ this . preferenceService . set ( 'editor.quickSuggestions' , quickSuggestions , PreferenceScope . User ) ,
202212 this . preferenceService . set ( 'arduino.window.autoScale' , autoScaleInterface , PreferenceScope . User ) ,
203213 this . preferenceService . set ( 'arduino.window.zoomLevel' , interfaceScale , PreferenceScope . User ) ,
204214 // this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User),
@@ -360,6 +370,13 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
360370 onChange = { this . autoSaveDidChange } />
361371 Auto save
362372 </ label >
373+ < label className = 'flex-line' >
374+ < input
375+ type = 'checkbox'
376+ checked = { this . state . quickSuggestions . other === true }
377+ onChange = { this . quickSuggestionsOtherDidChange } />
378+ Editor Quick Suggestions
379+ </ label >
363380 < label className = 'flex-line' >
364381 < input
365382 type = 'checkbox'
@@ -551,6 +568,21 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
551568 this . setState ( { autoSave : event . target . checked ? 'on' : 'off' } ) ;
552569 } ;
553570
571+ protected quickSuggestionsOtherDidChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
572+
573+ // need to persist react events through lifecycle https://reactjs.org/docs/events.html#event-pooling
574+ const newVal = event . target . checked ? true : false
575+
576+ this . setState ( prevState => {
577+ return {
578+ quickSuggestions : {
579+ ...prevState . quickSuggestions ,
580+ other : newVal
581+ }
582+ }
583+ } ) ;
584+ } ;
585+
554586 protected themeDidChange = ( event : React . ChangeEvent < HTMLSelectElement > ) => {
555587 const { selectedIndex } = event . target . options ;
556588 const theme = ThemeService . get ( ) . getThemes ( ) [ selectedIndex ] ;
0 commit comments