Use distance filter

This commit is contained in:
Zef Hemel
2022-03-29 12:13:46 +02:00
parent b89aee97d7
commit c6628927ba
15 changed files with 136 additions and 65 deletions
+2 -3
View File
@@ -29,9 +29,8 @@ functions:
command:
name: "Page: Rename"
pageComplete:
path: "./navigate.ts:pageComplete"
events:
- editor:complete
path: "./page.ts:pageComplete"
isCompleter: true
linkNavigate:
path: "./navigate.ts:linkNavigate"
command:
-15
View File
@@ -38,18 +38,3 @@ export async function clickNavigate(event: ClickEvent) {
await navigate(syntaxNode);
}
}
export async function pageComplete() {
let prefix = await syscall("editor.matchBefore", "\\[\\[[\\w\\s]*");
if (!prefix) {
return null;
}
let allPages = await syscall("space.listPages");
return {
from: prefix.from + 2,
options: allPages.map((pageMeta: any) => ({
label: pageMeta.name,
type: "page",
})),
};
}
+16
View File
@@ -110,6 +110,22 @@ export async function reindexCommand() {
await syscall("editor.flashNotification", "Reindexing done");
}
// Completion
export async function pageComplete() {
let prefix = await syscall("editor.matchBefore", "\\[\\[[\\w\\s]*");
if (!prefix) {
return null;
}
let allPages = await syscall("space.listPages");
return {
from: prefix.from + 2,
options: allPages.map((pageMeta: any) => ({
label: pageMeta.name,
type: "page",
})),
};
}
// Server functions
export async function reindexSpace() {
console.log("Clearing page index...");
+1 -1
View File
@@ -1,7 +1,7 @@
import { syscall } from "../lib/syscall";
function countWords(str: string): number {
var matches = str.match(/[\w\d\'\'-]+/gi);
const matches = str.match(/[\w\d\'-]+/gi);
return matches ? matches.length : 0;
}