Skip to content

Commit

Permalink
Fixing user-template include - Closes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
SilentVoid13 committed Jan 9, 2021
1 parent 7bedc4d commit 473916c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fuzzy_suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class TemplaterFuzzySuggestModal extends FuzzySuggestModal<TFile> {

let rel_pos = await this.get_cursor_location(content);
if (rel_pos.length !== 0) {
content = content.replace(new RegExp(TP_CURSOR), "");
content = content.replace(new RegExp(TP_CURSOR, "g"), "");
}
let current_pos = doc.getCursor();

Expand All @@ -110,7 +110,7 @@ export class TemplaterFuzzySuggestModal extends FuzzySuggestModal<TFile> {
if (new_content !== content) {
let pos = await this.get_cursor_location(new_content);
if (pos.length !== 0) {
new_content = new_content.replace(new RegExp(TP_CURSOR), "");
new_content = new_content.replace(new RegExp(TP_CURSOR, "g"), "");
}

await this.app.vault.modify(file, new_content);
Expand All @@ -122,6 +122,9 @@ export class TemplaterFuzzySuggestModal extends FuzzySuggestModal<TFile> {
}

async replace_templates(content: string) {
// Internal templates
content = await replace_internal_templates(this.app, content);

// User defined templates
for (let i = 0; i < this.plugin.settings.templates_pairs.length; i++) {
let template_pair = this.plugin.settings.templates_pairs[i];
Expand Down Expand Up @@ -149,11 +152,8 @@ export class TemplaterFuzzySuggestModal extends FuzzySuggestModal<TFile> {
new Notice("Error with the template n°" + (i+1) + " (check console for more informations)");
}
}
}
}

// Internal templates
content = await replace_internal_templates(this.app, content);

return content;
}

Expand Down

0 comments on commit 473916c

Please sign in to comment.