@@ -28,9 +28,10 @@ export class CaptureChoiceFormatter extends CompleteFormatter {
28
28
this . fileContent = fileContent ;
29
29
if ( ! choice || ! file || fileContent === null ) return input ;
30
30
31
- // Skip templater processing here since it's already been processed in formatContentOnly
32
- // Just position the already-formatted content in the file according to settings
33
- const formatted = await this . formatFileContent ( input , false ) ;
31
+ // Process templater here if we're using insert after or prepend or not capturing to active file
32
+ // This is needed because in these cases, the content won't be processed by templaterParseTemplate in CaptureChoiceEngine
33
+ const shouldRunTemplater = choice . insertAfter . enabled || choice . prepend || ! choice . captureToActiveFile ;
34
+ const formatted = await this . formatFileContent ( input , shouldRunTemplater ) ;
34
35
return formatted ;
35
36
}
36
37
@@ -49,7 +50,6 @@ export class CaptureChoiceFormatter extends CompleteFormatter {
49
50
formatted = this . replaceLinebreakInString ( formatted ) ;
50
51
51
52
// If runTemplater is true and we have a file, run the templater parsing
52
- // This will only be true during the first formatting stage (formatContentOnly)
53
53
if ( runTemplater && this . file ) {
54
54
const templaterFormatted = await templaterParseTemplate (
55
55
this . app ,
@@ -95,17 +95,10 @@ export class CaptureChoiceFormatter extends CompleteFormatter {
95
95
let formatted = await super . formatFileContent ( input ) ;
96
96
formatted = this . replaceLinebreakInString ( formatted ) ;
97
97
98
- // If we have a file, run templater parsing once in this first pass
99
- if ( this . file ) {
100
- const templaterFormatted = await templaterParseTemplate (
101
- this . app ,
102
- formatted ,
103
- this . file
104
- ) ;
105
- if ( templaterFormatted ) {
106
- formatted = templaterFormatted ;
107
- }
108
- }
98
+ // DON'T run templater parsing here - it will be handled either by:
99
+ // 1. CaptureChoiceEngine.run() for the active file + no insert after + no prepend case
100
+ // 2. formatContentWithFile() for all other cases
101
+ // This avoids double processing of templater commands
109
102
110
103
const formattedContentIsEmpty = formatted . trim ( ) === "" ;
111
104
if ( formattedContentIsEmpty ) return this . fileContent ;
0 commit comments