MCPcopy
hub / github.com/callumalpass/tasknotes / getTaskInfoSync

Function getTaskInfoSync

src/editor/TaskLinkOverlay.ts:592–632  ·  view source on GitHub ↗
(filePath: string, plugin: TaskNotesPlugin)

Source from the content-addressed store, hash-verified

590}
591
592function getTaskInfoSync(filePath: string, plugin: TaskNotesPlugin): TaskInfo | null {
593 // Validate inputs
594 if (!filePath || typeof filePath !== "string" || filePath.trim().length === 0) {
595 return null;
596 }
597
598 if (!plugin) {
599 return null;
600 }
601
602 try {
603 // Check for invalid characters
604 const basicInvalidChars = /[<>:"|?*]/;
605 const hasControlChars = filePath.split("").some((char) => {
606 const code = char.charCodeAt(0);
607 return code <= 31 || code === 127;
608 });
609
610 if (basicInvalidChars.test(filePath) || hasControlChars) {
611 return null;
612 }
613
614 // Use the same cached data access pattern as the views
615 // This gets the most up-to-date cached task info (updated immediately after any changes)
616 const cacheManager = plugin.cacheManager;
617 if (!cacheManager || !cacheManager.getCachedTaskInfoSync) {
618 return null;
619 }
620
621 const taskInfo = cacheManager.getCachedTaskInfoSync(filePath);
622
623 // Basic validation of task info structure
624 if (taskInfo && typeof taskInfo === "object" && taskInfo.title) {
625 return taskInfo;
626 }
627
628 return null;
629 } catch {
630 return null;
631 }
632}
633
634export function createTaskLinkOverlay(plugin: TaskNotesPlugin): Extension {
635 const viewPlugin = createTaskLinkViewPlugin(plugin);

Callers 1

buildTaskLinkDecorationsFunction · 0.85

Calls 1

getCachedTaskInfoSyncMethod · 0.80

Tested by

no test coverage detected