Code complete fixes and changelog
This commit is contained in:
@@ -34,14 +34,3 @@ functions:
|
||||
path: command.ts:convertToLiveQuery
|
||||
command:
|
||||
name: "Directive: Convert Query to Live Query"
|
||||
|
||||
# Templates
|
||||
insertEvalTemplate:
|
||||
redirect: template.insertTemplateText
|
||||
slashCommand:
|
||||
name: eval
|
||||
description: Evaluate a JavaScript expression
|
||||
value: |
|
||||
<!-- #eval |^| -->
|
||||
|
||||
<!-- /eval -->
|
||||
+27
-4
@@ -1,5 +1,5 @@
|
||||
import { CompleteEvent } from "$sb/app_event.ts";
|
||||
import { events } from "$sb/syscalls.ts";
|
||||
import { events, language } from "$sb/syscalls.ts";
|
||||
import {
|
||||
AttributeCompleteEvent,
|
||||
AttributeCompletion,
|
||||
@@ -7,11 +7,12 @@ import {
|
||||
|
||||
export async function queryComplete(completeEvent: CompleteEvent) {
|
||||
const fencedParent = completeEvent.parentNodes.find((node) =>
|
||||
node === "FencedCode:query"
|
||||
node.startsWith("FencedCode:query")
|
||||
);
|
||||
if (!fencedParent) {
|
||||
return null;
|
||||
}
|
||||
// First let's try to match the query source
|
||||
let querySourceMatch = /^\s*([\w\-_]*)$/.exec(
|
||||
completeEvent.linePrefix,
|
||||
);
|
||||
@@ -41,8 +42,10 @@ export async function queryComplete(completeEvent: CompleteEvent) {
|
||||
};
|
||||
}
|
||||
|
||||
querySourceMatch = /^\s*([\w\-_]*)/.exec(
|
||||
completeEvent.linePrefix,
|
||||
// If that doesn't work, let's try to match other bits of the query
|
||||
// For this we do need to find the query source, though, so let's look for it in fencedParent
|
||||
querySourceMatch = /^[\n\r\s]*([\w\-_]+)/.exec(
|
||||
fencedParent.slice("FencedCode:query".length),
|
||||
);
|
||||
const whereMatch =
|
||||
/(where|order\s+by|and|or|select(\s+[\w\s,]+)?)\s+([\w\-_]*)$/
|
||||
@@ -78,3 +81,23 @@ function attributeCompletionsToCMCompletion(
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function languageComplete(completeEvent: CompleteEvent) {
|
||||
const languagePrefix = /^```(\w*)$/.exec(
|
||||
completeEvent.linePrefix,
|
||||
);
|
||||
if (!languagePrefix) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const allLanguages = await language.listLanguages();
|
||||
return {
|
||||
from: completeEvent.pos - languagePrefix[1].length,
|
||||
options: allLanguages.map(
|
||||
(lang) => ({
|
||||
label: lang,
|
||||
type: "language",
|
||||
}),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ functions:
|
||||
events:
|
||||
- editor:complete
|
||||
|
||||
languageComplete:
|
||||
path: complete.ts:languageComplete
|
||||
events:
|
||||
- editor:complete
|
||||
|
||||
# Slash commands
|
||||
insertQuery:
|
||||
redirect: template.insertTemplateText
|
||||
|
||||
@@ -46,10 +46,10 @@ functions:
|
||||
redirect: insertTemplateText
|
||||
slashCommand:
|
||||
name: code
|
||||
description: Insert code block
|
||||
description: Insert fenced code block
|
||||
value: |
|
||||
```
|
||||
|^|
|
||||
```|^|
|
||||
|
||||
```
|
||||
|
||||
insertHRTemplate:
|
||||
|
||||
Reference in New Issue
Block a user