Use distance filter
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user