File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,8 @@ export class Templater {
302302 ) : Promise < void > {
303303 const { path } = file ;
304304 this . start_templater_task ( path ) ;
305+ const active_view =
306+ this . plugin . app . workspace . getActiveViewOfType ( MarkdownView ) ;
305307 const active_editor = this . plugin . app . workspace . activeEditor ;
306308 const active_file = get_active_file ( this . plugin . app ) ;
307309 const running_config = this . create_running_config (
@@ -326,7 +328,8 @@ export class Templater {
326328 if (
327329 active_file ?. path === file . path &&
328330 active_editor &&
329- active_editor . editor
331+ active_editor . editor &&
332+ active_view
330333 ) {
331334 let result = "" ;
332335 const { content, frontmatter } = get_frontmatter_and_content (
@@ -342,6 +345,9 @@ export class Templater {
342345 // https://github.com/SilentVoid13/Templater/issues/1231
343346 const editor = active_editor . editor ;
344347 editor . setSelection ( { line : 0 , ch : 0 } , { line : 0 , ch : 0 } ) ;
348+ // Save the file to ensure modifications saved to disk by the time `on_all_templates_executed` callback is executed
349+ // https://github.com/SilentVoid13/Templater/issues/1569
350+ await active_view . save ( ) ;
345351 } else {
346352 await this . plugin . app . vault . process ( file , ( data ) => {
347353 let result = "" ;
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ export class CursorJumper {
3535 } ) ;
3636 if ( active_editor instanceof MarkdownView ) {
3737 active_editor . currentMode . applyFoldInfo ( fold_info ) ;
38+ // Save the file to ensure modifications saved to disk by the time `on_all_templates_executed` callback is executed
39+ // https://github.com/SilentVoid13/Templater/issues/1569
40+ active_editor . save ( ) ;
3841 }
3942 }
4043 this . set_cursor_location ( positions ) ;
You can’t perform that action at this time.
0 commit comments