Fix hashtag indexing for tasks on inial sync

pull/452/head^2
Zef Hemel 2023-07-07 15:46:11 +02:00
parent e98495fb50
commit f0aaec7afc
1 changed files with 14 additions and 7 deletions

View File

@ -52,7 +52,7 @@ import {
xmlLanguage, xmlLanguage,
yamlLanguage, yamlLanguage,
} from "../common/deps.ts"; } from "../common/deps.ts";
import { SilverBulletHooks } from "../common/manifest.ts"; import { Manifest, SilverBulletHooks } from "../common/manifest.ts";
import { import {
loadMarkdownExtensions, loadMarkdownExtensions,
MDExt, MDExt,
@ -371,11 +371,14 @@ export class Editor {
this.eventHook.addLocalListener("plug:changed", async (fileName) => { this.eventHook.addLocalListener("plug:changed", async (fileName) => {
console.log("Plug updated, reloading:", fileName); console.log("Plug updated, reloading:", fileName);
system.unload(fileName); system.unload(fileName);
await system.load( const plug = await system.load(
// await this.space.readFile(fileName, "utf8"),
new URL(`/${fileName}`, location.href), new URL(`/${fileName}`, location.href),
createSandbox, createSandbox,
); );
if ((plug.manifest! as Manifest).syntax) {
// If there are syntax extensions, rebuild the markdown parser immediately
this.updateMarkdownParser();
}
this.plugsUpdated = true; this.plugsUpdated = true;
}); });
} }
@ -1065,10 +1068,7 @@ export class Editor {
await this.dispatchAppEvent("plugs:loaded"); await this.dispatchAppEvent("plugs:loaded");
} }
rebuildEditorState() { updateMarkdownParser() {
const editorView = this.editorView;
console.log("Rebuilding editor state");
// Load all syntax extensions // Load all syntax extensions
this.mdExtensions = loadMarkdownExtensions(this.system); this.mdExtensions = loadMarkdownExtensions(this.system);
// And reload the syscalls to use the new syntax extensions // And reload the syscalls to use the new syntax extensions
@ -1076,6 +1076,13 @@ export class Editor {
[], [],
markdownSyscalls(buildMarkdown(this.mdExtensions)), markdownSyscalls(buildMarkdown(this.mdExtensions)),
); );
}
rebuildEditorState() {
const editorView = this.editorView;
console.log("Rebuilding editor state");
this.updateMarkdownParser();
if (editorView && this.currentPage) { if (editorView && this.currentPage) {
// And update the editor if a page is loaded // And update the editor if a page is loaded