Skip to content

Commit 6722c9d

Browse files
committed
fix: use event.currentTarget to get editor
1 parent 0795945 commit 6722c9d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/CodeFormatManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ export default class CodeFormatManager {
6666
// Events from the explicit Atom command.
6767
this._subscriptions.add(
6868
atom.commands.add("atom-text-editor", "code-format:format-code", async (event) => {
69-
const editor = atom.workspace.getActiveTextEditor()
70-
if (!editor) {
69+
const editorElement = event.currentTarget
70+
if (!editorElement) {
7171
return
7272
}
73+
const editor = editorElement.getModel()
7374
// Make sure we halt everything when the editor gets destroyed.
7475
const edits = await this._formatCodeInTextEditor(editor)
7576
try {

0 commit comments

Comments
 (0)