Fix some nasty bug
This commit is contained in:
@@ -79,8 +79,8 @@ export async function updateMaterializedQueriesOnPage(pageName: string) {
|
||||
for (let {
|
||||
key,
|
||||
page,
|
||||
value: {item, children},
|
||||
} of await syscall("index.scanPrefixGlobal", "it:")) {
|
||||
value: { item, children },
|
||||
}; of await syscall("index.scanPrefixGlobal", "it:")) {
|
||||
let [, pos] = key.split(":");
|
||||
if (!filter || (filter && item.includes(filter))) {
|
||||
results.push(`* [[${page}@${pos}]] ${item}`);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
emoji-data.txt
|
||||
@@ -0,0 +1,3 @@
|
||||
build:
|
||||
curl https://unicode.org/Public/emoji/14.0/emoji-test.txt > emoji-data.txt
|
||||
node build.js
|
||||
@@ -0,0 +1,17 @@
|
||||
// Generates emoji.json from emoji-data.txt
|
||||
const { readFileSync, writeFileSync } = require("fs");
|
||||
|
||||
const emojiRe = /#\s([^\s]+)\s+E[^\s]+\s+(.+)$/;
|
||||
|
||||
let text = readFileSync("emoji-data.txt", "utf-8");
|
||||
const lines = text.split("\n").filter((line) => !line.startsWith("#"));
|
||||
|
||||
let emoji = [];
|
||||
for (const line of lines) {
|
||||
let match = emojiRe.exec(line);
|
||||
if (match) {
|
||||
emoji.push([match[1], match[2].toLowerCase().replaceAll(/\W+/g, "_")]);
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync("emoji.json", JSON.stringify(emoji));
|
||||
@@ -0,0 +1,4 @@
|
||||
functions:
|
||||
emojiCompleter:
|
||||
path: "./emoji.ts:emojiCompleter"
|
||||
isCompleter: true
|
||||
@@ -0,0 +1,26 @@
|
||||
// @ts-ignore
|
||||
import emojis from "./emoji.json";
|
||||
import { syscall } from "../lib/syscall";
|
||||
|
||||
const emojiMatcher = /\(([^\)]+)\)\s+(.+)$/;
|
||||
|
||||
export async function emojiCompleter() {
|
||||
let prefix = await syscall("editor.matchBefore", ":[\\w\\s]*");
|
||||
if (!prefix) {
|
||||
return null;
|
||||
}
|
||||
const textPrefix = prefix.text.substring(1); // Cut off the initial :
|
||||
let filteredEmoji = emojis.filter(([_, shortcode]) =>
|
||||
shortcode.includes(textPrefix)
|
||||
);
|
||||
|
||||
return {
|
||||
from: prefix.from,
|
||||
filter: false,
|
||||
options: filteredEmoji.map(([emoji, shortcode]) => ({
|
||||
detail: shortcode,
|
||||
label: emoji,
|
||||
type: "emoji",
|
||||
})),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user