Skip to content

Commit cae0d92

Browse files
committed
Fixed bug whereby noncompliant patterns would not be filtered correctly, causing other patterns to be filtered in their place.
1 parent f444bac commit cae0d92

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-apply-patterns",
33
"name": "Apply Patterns",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"minAppVersion": "0.14.5",
66
"description": "Apply custom patterns of find-and-replace in succession to text.",
77
"author": "Jacob Levernier",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-apply-patterns",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "An Obsidian plugin for applying patterns of find and replace in succession.",
55
"main": "main.js",
66
"scripts": {

src/FilterPatterns.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ import {
1010

1111
export const filterPatterns = (command?: Command): number[] => {
1212
const patterns = getSettings().patterns;
13+
1314
let patternIndexes: number[] = getSettings()
14-
.patterns.filter(
15-
(pattern: Pattern) =>
16-
pattern.rules.length > 0 &&
17-
pattern.rules.every((rule: PatternRule) => rule.from !== ''),
15+
.patterns
16+
.map((pattern: Pattern, patternIndex: number) => {
17+
return {pattern, patternIndex}
18+
})
19+
.filter(
20+
(p: {pattern: Pattern, patternIndex: number}) =>
21+
p.pattern.rules.length > 0 &&
22+
p.pattern.rules.every((rule: PatternRule) => rule.from !== '')
1823
)
19-
.map((_: Pattern, patternIndex: number) => {
20-
return patternIndex;
21-
});
24+
.map((p: {pattern: Pattern, patternIndex: number}) => p.patternIndex );
2225

2326
if (command !== undefined && command.patternFilter !== '') {
2427
try {

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"1.4.1": "0.13.9",
1111
"2.0.0": "0.13.9",
1212
"2.1.0": "0.14.5",
13-
"2.1.1": "0.14.5"
13+
"2.1.1": "0.14.5",
14+
"2.1.2": "1.0.0"
1415
}

0 commit comments

Comments
 (0)