Skip to content

Commit

Permalink
Fixed bug whereby noncompliant patterns would not be filtered correct…
Browse files Browse the repository at this point in the history
…ly, causing other patterns to be filtered in their place.
  • Loading branch information
jglev committed Feb 26, 2023
1 parent f444bac commit cae0d92
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-apply-patterns",
"name": "Apply Patterns",
"version": "2.1.1",
"version": "2.1.2",
"minAppVersion": "0.14.5",
"description": "Apply custom patterns of find-and-replace in succession to text.",
"author": "Jacob Levernier",
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": "obsidian-apply-patterns",
"version": "2.1.1",
"version": "2.1.2",
"description": "An Obsidian plugin for applying patterns of find and replace in succession.",
"main": "main.js",
"scripts": {
Expand Down
17 changes: 10 additions & 7 deletions src/FilterPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import {

export const filterPatterns = (command?: Command): number[] => {
const patterns = getSettings().patterns;

let patternIndexes: number[] = getSettings()
.patterns.filter(
(pattern: Pattern) =>
pattern.rules.length > 0 &&
pattern.rules.every((rule: PatternRule) => rule.from !== ''),
.patterns
.map((pattern: Pattern, patternIndex: number) => {
return {pattern, patternIndex}
})
.filter(
(p: {pattern: Pattern, patternIndex: number}) =>
p.pattern.rules.length > 0 &&
p.pattern.rules.every((rule: PatternRule) => rule.from !== '')
)
.map((_: Pattern, patternIndex: number) => {
return patternIndex;
});
.map((p: {pattern: Pattern, patternIndex: number}) => p.patternIndex );

if (command !== undefined && command.patternFilter !== '') {
try {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"1.4.1": "0.13.9",
"2.0.0": "0.13.9",
"2.1.0": "0.14.5",
"2.1.1": "0.14.5"
"2.1.1": "0.14.5",
"2.1.2": "1.0.0"
}

0 comments on commit cae0d92

Please sign in to comment.