Skip to content

Commit

Permalink
Capture frontmatter insertion fix and replace linebreak in insert after
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jul 15, 2021
1 parent 9d2ca05 commit b165bff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Quickly add new pages or content to your vault.
You can also do a [manual installation](docs/ManualInstallation.md).

## What's new?
### 0.3.6 - 0.3.7
### 0.3.6 - 0.3.8
- Added setting to create the 'Insert After' line if it isn't found.
- (HOTFIX) Escape regular expression special characters in Insert After when searching for it
- (HOTFIX) Insert _after_ frontmatter

### 0.3.5
- You can now execute [inline JavaScript](docs/InlineScripts.md) in templates or captures.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quickadd",
"name": "QuickAdd",
"version": "0.3.7",
"version": "0.3.8",
"minAppVersion": "0.12.5",
"description": "Quickly add new pages or content to your vault.",
"author": "Christian B. B. Houmann",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickadd",
"version": "0.3.7",
"version": "0.3.8",
"description": "Quickly add new pages or content to your vault.",
"main": "main.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/formatters/captureChoiceFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ export class CaptureChoiceFormatter extends CompleteFormatter {
const targetPosition = fileContentLines.findIndex(line => targetRegex.test(line));
if (targetPosition === -1) {
if (this.choice.insertAfter?.createIfNotFound) {
const insertAfterLineAndFormatted: string = `${await this.format(this.choice.insertAfter.after)}\n${formatted}`;
const insertAfterLine: string = this.replaceLinebreakInString(await this.format(this.choice.insertAfter.after));
const insertAfterLineAndFormatted: string = `${insertAfterLine}\n${formatted}`;

if (this.choice.insertAfter?.createIfNotFoundLocation === CREATE_IF_NOT_FOUND_TOP) {
const frontmatterEndPosition = this.file ? await this.getFrontmatterEndPosition(this.file) : 0;
return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, frontmatterEndPosition - 1);
return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, frontmatterEndPosition);
}
else {
return this.insertTextAfterPositionInBody(insertAfterLineAndFormatted, this.fileContent, fileContentLines.length - 1);
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"0.2.16": "0.12.4",
"0.3.7": "0.12.5"
"0.3.8": "0.12.5"
}

0 comments on commit b165bff

Please sign in to comment.