Skip to content

Commit

Permalink
fix: More predictable search of task descriptions for dependencies
Browse files Browse the repository at this point in the history
By using simple search instead of fuzzy search.
  • Loading branch information
claremacrae committed Mar 3, 2024
1 parent f8f0a73 commit 01d7383
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ui/DependencyHelpers.ts
@@ -1,4 +1,4 @@
import { type FuzzyMatch, prepareFuzzySearch } from 'obsidian';
import { type FuzzyMatch, prepareSimpleSearch } from 'obsidian';
import type { Task } from '../Task/Task';
import { GlobalFilter } from '../Config/GlobalFilter';

Expand All @@ -15,12 +15,12 @@ export function descriptionAdjustedForDependencySearch(task: Task) {
return GlobalFilter.getInstance().removeAsWordFrom(task.description);
}

function fuzzySearchDescriptionWithoutTags(query: string, allTasks: Task[]): Task[] {
function searchDescriptionWithoutTags(query: string, allTasks: Task[]): Task[] {
if (query === '') {
return allTasks;
}

const preparedSearch = prepareFuzzySearch(query);
const preparedSearch = prepareSimpleSearch(query);

// The cutoff was chosen empirically, to filter out very poor matches:
const minimumScoreCutoff = -4.0;
Expand Down Expand Up @@ -58,7 +58,7 @@ export function searchForCandidateTasksForDependency(
blockedBy: Task[],
blocking: Task[],
) {
let results = fuzzySearchDescriptionWithoutTags(search, allTasks);
let results = searchDescriptionWithoutTags(search, allTasks);

results = results.filter((item) => {
// Do not offer to depend on DONE, CANCELLED or NON_TASK tasks:
Expand Down

0 comments on commit 01d7383

Please sign in to comment.