Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27,224 changes: 27,224 additions & 0 deletions .pnp.cjs

Large diffs are not rendered by default.

2,126 changes: 2,126 additions & 0 deletions .pnp.loader.mjs

Large diffs are not rendered by default.

Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 0 additions & 1 deletion apps/vscode/.yarnrc

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "quarto",
"name": "quarto-editor-tools-monorepo",
"version": "1.86.0",
"private": true,
"workspaces": [
Expand All @@ -26,5 +26,6 @@
"eslint-config-custom": "*",
"prettier": "^2.5.1",
"turbo": "^1.8.5"
}
},
"packageManager": "[email protected]"
}
6 changes: 3 additions & 3 deletions packages/_annotated-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"main": "src/index.ts",
"types": "src/index.ts",
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
"@quarto/_mapped-string": "*",
"@quarto/_tidyverse-errors": "*"
"@quarto/_tidyverse-errors": "*",
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
12 changes: 6 additions & 6 deletions packages/_json-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"main": "src/index.ts",
"types": "src/index.ts",
"dependencies": {
"tsconfig": "*",
"build": "*",
"typescript": "^5.4.2",
"regexpp": "^3.2.0",
"ansi-colors": "^4.1.3",
"@quarto/_annotated-json": "*",
"@quarto/_mapped-string": "*",
"@quarto/_tidyverse-errors": "*",
"@quarto/_annotated-json": "*"
"ansi-colors": "^4.1.3",
"build": "*",
"regexpp": "^3.2.0",
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/_mapped-string/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"main": "src/index.ts",
"types": "src/index.ts",
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
"@quarto/_tidyverse-errors": "*",
"ansi-colors": "^4.1.3",
"@quarto/_tidyverse-errors": "*"
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/_tidyverse-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"ansi-colors": "^4.1.3",
"tsconfig": "*",
"typescript": "^5.4.2",
"ansi-colors": "^4.1.3"
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
10 changes: 6 additions & 4 deletions packages/annotated-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
},
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
"@quarto/mapped-string": "^0.1.8",
"@quarto/tidyverse-errors": "^0.1.9"
"@quarto/tidyverse-errors": "^0.1.9",
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
3 changes: 1 addition & 2 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"esbuild-plugin-copy": "^2.0.1",
"tsconfig": "*",
"typescript": "^4.5.2"
},
"dependencies": {}
}
}
6 changes: 2 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-attrs": "^4.1.0",
"markdown-it": "^13.0.1",
"markdown-it-attrs": "^4.1.6",
"tsconfig": "*",
"typescript": "^4.5.2"
},
"devDependencies": {
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-attrs": "^4.1.0"
}
}
6 changes: 3 additions & 3 deletions packages/editor-codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"@codemirror/search": "^6.2.3",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.7.3",
"@quarto/_annotated-json": "*",
"@quarto/_mapped-string": "*",
"@quarto/_tidyverse-errors": "*",
"@replit/codemirror-vscode-keymap": "^6.0.2",
"codemirror": "^6.0.1",
"core": "*",
"editor": "*",
"editor-core": "*",
"editor-types": "*",
"@quarto/_tidyverse-errors": "*",
"@quarto/_mapped-string": "*",
"@quarto/_annotated-json": "*",
"markdown-it": "^13.0.1",
"prosemirror-commands": "^1.3.1",
"prosemirror-gapcursor": "^1.3.1",
Expand Down
64 changes: 41 additions & 23 deletions packages/editor-codemirror/src/behaviors/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,52 @@ const compareBySortText = (a: CompletionItem, b: CompletionItem) => {
}
};

// compute from
const itemFrom = (item: CompletionItem, contextPos: number) => {
// compute from
return item.textEdit
? InsertReplaceEdit.is(item.textEdit)
? contextPos - (item.textEdit.insert.end.character - item.textEdit.insert.start.character)
: TextEdit.is(item.textEdit)
? contextPos - (item.textEdit.range.end.character - item.textEdit.range.start.character)
: contextPos
: contextPos;
/**
* returns the offset into the document of the beginning of a completion item.
*/
const itemFrom = (item: CompletionItem, cvContext: CodeViewCompletionContext, contextPos: number) => {
if (item.textEdit !== undefined) {
if (InsertReplaceEdit.is(item.textEdit)) {
const endLine = cvContext.code[item.textEdit.insert.end.line];
// we have to "snap" (Math.min) the end of the insertion to the end of the line
// because completions give positions past the end of the line.
// e.g. typing `lib` gives completion `library` with start.character = 0, end.character = 7
// but we only expect it to replace characters 0 thru 3.
const end = Math.min(item.textEdit.insert.end.character, endLine.length);

const replaceLength = end - item.textEdit.insert.start.character;
return contextPos - replaceLength;
}
if (TextEdit.is(item.textEdit)) {
const endLine = cvContext.code[item.textEdit.range.end.line];
// see comment above for an explanation of why we use Math.min here.
const end = Math.min(item.textEdit.range.end.character, endLine.length);

const replaceLength = end - item.textEdit.range.start.character;

return contextPos - replaceLength;
}
}
return contextPos;
};

/**
* replaceText for a given CompletionItem is the text that is already in the document
* that that CompletionItem will replace.
*
*
* Example 1: if you are typing `lib` and get the completion `library`, then this function
* will give `lib`.
* Example 2: if you are typing `os.a` and get the completion `abc`, then this function
* will give `a`.
*/
const getReplaceText = (context: CompletionContext, item: CompletionItem) =>
context.state.sliceDoc(itemFrom(item, context.pos), context.pos);
const getReplaceText = (context: CompletionContext, cvContext: CodeViewCompletionContext, item: CompletionItem) =>
context.state.sliceDoc(itemFrom(item, cvContext, context.pos), context.pos);

const makeCompletionItemApplier = (item: CompletionItem, context: CompletionContext) =>
const makeCompletionItemApplier = (item: CompletionItem, cvContext: CodeViewCompletionContext, context: CompletionContext) =>
(view: EditorView, completion: Completion) => {
// compute from
const from = itemFrom(item, context.pos);
const from = itemFrom(item, cvContext, context.pos);

// handle snippets
const insertText = item.textEdit?.newText ?? (item.insertText || item.label);
Expand All @@ -156,11 +174,11 @@ const makeCompletionItemApplier = (item: CompletionItem, context: CompletionCont
}
};

const sortTextItemsBoostScore = (context: CompletionContext, items: CompletionItem[], index: number) => {
const sortTextItemsBoostScore = (context: CompletionContext, cvContext: CodeViewCompletionContext, items: CompletionItem[], index: number) => {
const total = items.length;
const item = items[index];
// compute replaceText
const replaceText = getReplaceText(context, item);
const replaceText = getReplaceText(context, cvContext, item);

// if the replaceText doesn't start with "." then bury items that do
if (!replaceText.startsWith(".") && item.label.startsWith(".")) {
Expand All @@ -177,14 +195,14 @@ const sortTextItemsBoostScore = (context: CompletionContext, items: CompletionIt
}
};

const defaultBoostScore = (context: CompletionContext, items: CompletionItem[], index: number) => {
const defaultBoostScore = (context: CompletionContext, cvContext: CodeViewCompletionContext, items: CompletionItem[], index: number) => {
const item = items[index];

const replaceText = getReplaceText(context, item);
const replaceText = getReplaceText(context, cvContext, item);

// if you haven't typed into the completions yet (for example after a `.`) then
// score items starting with non-alphabetic characters -1, everything else 0.
if (replaceText.length === 0) return isLetter(item.label[0]) ? 0 : -1;
// score items starting with non-alphabetic characters -100, everything else 0.
if (replaceText.length === 0) return isLetter(item.label[0]) ? 0 : -100;

// We filter items by replaceText inclusion before scoring,
// so i is garaunteed to be an index into `item.label`...
Expand Down Expand Up @@ -233,7 +251,7 @@ async function getCompletions(
if (item.textEdit === undefined && token) return false;

// require at least inclusion
const replaceText = getReplaceText(context, item).toLowerCase();
const replaceText = getReplaceText(context, cvContext, item).toLowerCase();
return item.label.toLowerCase().includes(replaceText) ||
item.insertText?.toLowerCase().includes(replaceText);
});
Expand All @@ -249,8 +267,8 @@ async function getCompletions(
detail: !item.documentation ? item.detail : undefined,
type: vsKindToType(item.kind),
info: () => infoNodeForItem(item),
apply: makeCompletionItemApplier(item, context),
boost: boostScore(context, filteredItems, index)
apply: makeCompletionItemApplier(item, cvContext, context),
boost: boostScore(context, cvContext, filteredItems, index)
};
});

Expand Down
16 changes: 9 additions & 7 deletions packages/json-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
"license": "MIT",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"dependencies": {
"tsconfig": "*",
"build": "*",
"typescript": "^5.4.2",
"regexpp": "^3.2.0",
"ansi-colors": "^4.1.3",
"@quarto/annotated-json": "^0.1.4",
"@quarto/mapped-string": "^0.1.8",
"@quarto/tidyverse-errors": "^0.1.9",
"@quarto/annotated-json": "^0.1.4"
"ansi-colors": "^4.1.3",
"build": "*",
"regexpp": "^3.2.0",
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
10 changes: 6 additions & 4 deletions packages/mapped-string/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
},
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"dependencies": {
"tsconfig": "*",
"typescript": "^5.4.2",
"@quarto/tidyverse-errors": "^0.1.9",
"ansi-colors": "^4.1.3",
"@quarto/tidyverse-errors": "^0.1.9"
"tsconfig": "*",
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/ojs/external-observablehq-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "6.0.2",
"author": {
"name": "quarto-dev (RStudio PBC).",
"url": "https://quarto.org"
"url": "https://quarto.org"
},
"license": "ISC",
"type": "module",
Expand Down
16 changes: 8 additions & 8 deletions packages/ojs/quarto-ojs-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
"license": "ISC",
"dependencies": {
"@observablehq/inputs": "^0.10.4",
"external-alex-garcia-unofficial-observablehq-compiler": "*",
"external-observablehq-parser": "*",
"external-observablehq-runtime": "*",
"external-observablehq-stdlib": "*",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^13.3.0",
"acorn-walk": "^8.2.0",
"eslint": "^7.32.0",
"exceljs": "^4.3.0",
"external-alex-garcia-unofficial-observablehq-compiler": "*",
"external-observablehq-parser": "*",
"external-observablehq-runtime": "*",
"external-observablehq-stdlib": "*",
"mime": "^3.0.0",
"node-fetch": "^2.6.1",
"rollup": "^3.2.5",
"@rollup/plugin-json": "^5.0.1",
"rollup-plugin-terser": "^7.0.2",
"mime": "^3.0.0",
"acorn-walk": "^8.2.0"
"rollup-plugin-terser": "^7.0.2"
}
}
8 changes: 5 additions & 3 deletions packages/tidyverse-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"license": "MIT",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"dependencies": {
"ansi-colors": "^4.1.3",
"tsconfig": "*",
"typescript": "^5.4.2",
"ansi-colors": "^4.1.3"
"typescript": "^5.4.2"
},
"devDependencies": {
"tsx": "^4.7.1"
Expand Down
Loading
Loading