@@ -16,7 +16,7 @@ export default class PrettierPlugin extends Plugin {
16
16
private formatter ! : Formatter ;
17
17
private lastActiveFile : TFile | null = null ;
18
18
private events : EventRef [ ] = [ ] ;
19
- private originalSaveCallback : Command [ "callback " ] ;
19
+ private originalSaveCallback : Command [ "checkCallback " ] ;
20
20
21
21
override async onload ( ) {
22
22
await this . loadSettings ( ) ;
@@ -118,27 +118,27 @@ export default class PrettierPlugin extends Plugin {
118
118
119
119
private hookSaveCommands ( ) {
120
120
const saveCommand = this . app . commands . commands [ "editor:save-file" ] ;
121
- const saveCallback = saveCommand ?. callback ;
121
+ const saveCallback = saveCommand ?. checkCallback ;
122
122
if ( ! saveCommand || ! saveCallback ) return ;
123
123
124
124
this . originalSaveCallback = saveCallback ;
125
- saveCommand . callback = async ( ) => {
125
+ saveCommand . checkCallback = checking => {
126
+ if ( checking ) return saveCallback ( checking ) ;
127
+
126
128
const view = this . app . workspace . getActiveViewOfType ( MarkdownView ) ;
127
129
if ( view ) {
128
- await this . withPerformanceNotice ( ( ) =>
129
- this . formatter . formatOnSave ( view . editor , view . file ) ,
130
- ) ;
130
+ withPerfNotice ( ( ) => this . formatter . formatOnSave ( view . editor , view . file ) ) ;
131
131
}
132
132
133
- await saveCallback ( ) ;
133
+ saveCallback ( checking ) ;
134
134
} ;
135
135
}
136
136
137
137
private unhookSaveCommands ( ) {
138
138
const saveCommand = this . app . commands . commands [ "editor:save-file" ] ;
139
139
if ( ! saveCommand || ! this . originalSaveCallback ) return ;
140
140
141
- saveCommand . callback = this . originalSaveCallback ;
141
+ saveCommand . checkCallback = this . originalSaveCallback ;
142
142
}
143
143
144
144
private registerMenu ( ) {
0 commit comments