Skip to content

Commit 4e8690e

Browse files
authored
Merge pull request #282 from cooklang/feat/editor-file-reference-autocomplete
2 parents c5971c8 + 5b8f35e commit 4e8690e

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cooklang-find = { version = "0.5.0" }
4343
cooklang-import = "0.8.7"
4444
cooklang-sync-client = { version = "0.4.8", optional = true }
4545
libsqlite3-sys = { version = "0.35", features = ["bundled"], optional = true }
46-
cooklang-language-server = "0.2.0"
46+
cooklang-language-server = "0.2.1"
4747
cooklang-reports = { version = "0.2.2" }
4848
directories = "6"
4949
fluent = "0.16"

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CookCLI
22

3-
A command-line interface for managing and working with Cooklang recipes.
3+
CookCLI is a free, open-source command-line tool for working with [Cooklang](https://cooklang.org/docs/spec/) recipe files. It parses `.cook` files, generates combined shopping lists from multiple recipes, runs a local web server to browse your collection, imports recipes from websites, and scales servings — all from the terminal.
44

55
## Commands
66

static/js/src/editor.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async function cooklangCompletions(context) {
4040
const textBefore = line.text.slice(0, pos - line.from);
4141

4242
// Check for trigger characters (@, #, ~)
43-
const match = textBefore.match(/[@#~]([a-zA-Z0-9_]*)$/);
43+
// Include . / - in character class so @./path file references trigger completion
44+
const match = textBefore.match(/[@#~]([a-zA-Z0-9_./\-]*)$/);
4445
if (!match) return null;
4546

4647
const prefix = match[1];
@@ -53,9 +54,14 @@ async function cooklangCompletions(context) {
5354

5455
return {
5556
from: from,
57+
// Keep completion open while user types path chars; CodeMirror's
58+
// built-in FuzzyMatcher handles client-side narrowing.
59+
validFor: /^[a-zA-Z0-9_./\-]*$/,
5660
options: items.map(item => {
57-
const type = item.kind === 6 ? 'variable' : item.kind === 14 ? 'keyword' : 'text';
58-
const text = item.insertText || item.label;
61+
const type = item.kind === 17 ? 'file' : item.kind === 6 ? 'variable' : item.kind === 14 ? 'keyword' : 'text';
62+
// Prefer textEdit.newText (used by recipe references with explicit ranges),
63+
// then insertText, then label
64+
const text = item.textEdit?.newText || item.insertText || item.label;
5965

6066
// Check if LSP sent a snippet (insertTextFormat === 2)
6167
if (item.insertTextFormat === 2 && text.includes('$')) {

0 commit comments

Comments
 (0)