File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -96,25 +96,24 @@ export default class CodeFormatManager {
96
96
)
97
97
}
98
98
99
- _handleEvent ( event : FormatEvent ) : Observable < unknown > {
99
+ async _handleEvent ( event : FormatEvent ) {
100
100
const { editor } = event
101
101
switch ( event . type ) {
102
- case "command" :
103
- return this . _formatCodeInTextEditor ( editor )
104
- . do ( ( edits ) => {
105
- applyTextEditsToBuffer ( editor . getBuffer ( ) , edits )
106
- } )
107
- . map ( ( result ) => {
102
+ case "command" : {
103
+ const edits = await this . _formatCodeInTextEditor ( editor )
104
+ try {
105
+ applyTextEditsToBuffer ( editor . getBuffer ( ) , edits ) . forEach ( ( result ) => {
108
106
if ( ! result ) {
109
107
throw new Error ( "No code formatting providers found!" )
110
108
}
111
109
} )
112
- . catch ( ( err ) => {
113
- atom . notifications . addError ( `Failed to format code: ${ err . message } ` , {
114
- detail : err . detail ,
115
- } )
116
- return Observable . empty ( )
110
+ } catch ( err ) {
111
+ atom . notifications . addError ( `Failed to format code: ${ err . message } ` , {
112
+ detail : err . detail ,
117
113
} )
114
+ }
115
+ break
116
+ }
118
117
case "type" :
119
118
return this . _formatCodeOnTypeInTextEditor ( editor , event . edit ) . catch ( ( err ) => {
120
119
getLogger ( "code-format" ) . warn ( "Failed to format code on type:" , err )
You can’t perform that action at this time.
0 commit comments