Skip to content

Commit a92d37d

Browse files
committed
fix: remove rxjs from _handleEvent command case
1 parent 4ab7bfa commit a92d37d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/CodeFormatManager.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,24 @@ export default class CodeFormatManager {
9696
)
9797
}
9898

99-
_handleEvent(event: FormatEvent): Observable<unknown> {
99+
async _handleEvent(event: FormatEvent) {
100100
const { editor } = event
101101
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) => {
108106
if (!result) {
109107
throw new Error("No code formatting providers found!")
110108
}
111109
})
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,
117113
})
114+
}
115+
break
116+
}
118117
case "type":
119118
return this._formatCodeOnTypeInTextEditor(editor, event.edit).catch((err) => {
120119
getLogger("code-format").warn("Failed to format code on type:", err)

0 commit comments

Comments
 (0)