Skip to content

Commit 64bb907

Browse files
committed
use sourceWithYaml for code cell location
1 parent 7fecd6d commit 64bb907

File tree

3 files changed

+63
-65
lines changed

3 files changed

+63
-65
lines changed

src/core/lib/yaml-intelligence/yaml-intelligence.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,9 @@ async function automationFromGoodParseMarkdown(
789789
if (kind === "completions") {
790790
let foundCell = undefined;
791791
for (const cell of result.cells) {
792-
const size = lines(cell.source.value).length;
792+
// use sourceWithYaml when it exists (code cells)
793+
// but otherwise use cell.source (metadata cells)
794+
const size = lines((cell.sourceWithYaml || cell.source).value).length;
793795
if (size + cell.cellStartLine > position.row) {
794796
foundCell = cell;
795797
break;

src/resources/editor/tools/vs-code.mjs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6996,21 +6996,18 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
69966996
var __getOwnPropNames = Object.getOwnPropertyNames;
69976997
var __getProtoOf = Object.getPrototypeOf;
69986998
var __hasOwnProp = Object.prototype.hasOwnProperty;
6999-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
70006999
var __commonJS = (cb, mod) => function __require() {
7001-
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7000+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
70027001
};
7003-
var __reExport = (target, module, desc) => {
7004-
if (module && typeof module === "object" || typeof module === "function") {
7005-
for (let key of __getOwnPropNames(module))
7006-
if (!__hasOwnProp.call(target, key) && key !== "default")
7007-
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
7002+
var __copyProps = (to, from, except, desc) => {
7003+
if (from && typeof from === "object" || typeof from === "function") {
7004+
for (let key of __getOwnPropNames(from))
7005+
if (!__hasOwnProp.call(to, key) && key !== except)
7006+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
70087007
}
7009-
return target;
7010-
};
7011-
var __toModule = (module) => {
7012-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
7008+
return to;
70137009
};
7010+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
70147011

70157012
// ../../../resources/editor/tools/yaml/tree-sitter-yaml.json
70167013
var require_tree_sitter_yaml = __commonJS({
@@ -18987,8 +18984,8 @@ var noColor = typeof (Deno2 && Deno2.noColor) === "boolean" ? Deno2.noColor : tr
1898718984
var enabled = !noColor;
1898818985
function code(open, close) {
1898918986
return {
18990-
open: `[${open.join(";")}m`,
18991-
close: `[${close}m`,
18987+
open: `\x1B[${open.join(";")}m`,
18988+
close: `\x1B[${close}m`,
1899218989
regexp: new RegExp(`\\x1b\\[${close}m`, "g")
1899318990
};
1899418991
}
@@ -19198,7 +19195,7 @@ function resolveCaseConventionRegex(keys, conventions) {
1919819195
};
1919919196
}
1920019197
const disallowedNearMisses = [];
19201-
const foundConventions = new Set();
19198+
const foundConventions = /* @__PURE__ */ new Set();
1920219199
for (const key of keys) {
1920319200
const found = detectCaseConvention(key);
1920419201
if (found) {
@@ -19431,7 +19428,7 @@ async function getTreeSitter() {
1943119428
}
1943219429
await Parser.init();
1943319430
_parser = new Parser();
19434-
const treeSitterYamlJson = await Promise.resolve().then(() => __toModule(require_tree_sitter_yaml()));
19431+
const treeSitterYamlJson = await Promise.resolve().then(() => __toESM(require_tree_sitter_yaml()));
1943519432
const YAML = await Parser.Language.load(new Uint8Array(treeSitterYamlJson.data));
1943619433
_parser.setLanguage(YAML);
1943719434
return _parser;
@@ -20458,7 +20455,7 @@ function fromDecimalCode(c) {
2045820455
return -1;
2045920456
}
2046020457
function simpleEscapeSequence(c) {
20461-
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
20458+
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
2046220459
}
2046320460
function charFromCodepoint(c) {
2046420461
if (c <= 65535) {
@@ -20468,10 +20465,11 @@ function charFromCodepoint(c) {
2046820465
}
2046920466
var simpleEscapeCheck = new Array(256);
2047020467
var simpleEscapeMap = new Array(256);
20471-
for (var i = 0; i < 256; i++) {
20468+
for (i = 0; i < 256; i++) {
2047220469
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
2047320470
simpleEscapeMap[i] = simpleEscapeSequence(i);
2047420471
}
20472+
var i;
2047520473
function State$1(input, options) {
2047620474
this.input = input;
2047720475
this.filename = options["filename"] || null;
@@ -20858,7 +20856,7 @@ function readDoubleQuotedScalar(state, nodeIndent) {
2085820856
throwError(state, "unexpected end of the stream within a double quoted scalar");
2085920857
}
2086020858
function readFlowCollection(state, nodeIndent) {
20861-
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
20859+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
2086220860
ch = state.input.charCodeAt(state.position);
2086320861
if (ch === 91) {
2086420862
terminator = 93;
@@ -21079,7 +21077,7 @@ function readBlockSequence(state, nodeIndent) {
2107921077
return false;
2108021078
}
2108121079
function readBlockMapping(state, nodeIndent, flowIndent) {
21082-
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
21080+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
2108321081
if (state.firstTabInLine !== -1)
2108421082
return false;
2108521083
if (state.anchor !== null) {
@@ -21430,8 +21428,8 @@ function readDocument(state) {
2143021428
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2143121429
state.version = null;
2143221430
state.checkLineBreaks = state.legacy;
21433-
state.tagMap = Object.create(null);
21434-
state.anchorMap = Object.create(null);
21431+
state.tagMap = /* @__PURE__ */ Object.create(null);
21432+
state.anchorMap = /* @__PURE__ */ Object.create(null);
2143521433
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2143621434
skipSeparationSpace(state, true, -1);
2143721435
ch = state.input.charCodeAt(state.position);
@@ -22438,8 +22436,8 @@ var DataSet = class {
2243822436
return this._set2021 || (this._set2021 = new Set(this._raw2021.split(" ")));
2243922437
}
2244022438
};
22441-
var gcNameSet = new Set(["General_Category", "gc"]);
22442-
var scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
22439+
var gcNameSet = /* @__PURE__ */ new Set(["General_Category", "gc"]);
22440+
var scNameSet = /* @__PURE__ */ new Set(["Script", "Script_Extensions", "sc", "scx"]);
2244322441
var gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "");
2244422442
var scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi");
2244522443
var binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict");
@@ -22701,8 +22699,8 @@ var RegExpValidator = class {
2270122699
this._lastValValue = "";
2270222700
this._lastAssertionIsQuantifiable = false;
2270322701
this._numCapturingParens = 0;
22704-
this._groupNames = new Set();
22705-
this._backreferenceNames = new Set();
22702+
this._groupNames = /* @__PURE__ */ new Set();
22703+
this._backreferenceNames = /* @__PURE__ */ new Set();
2270622704
this._options = options || {};
2270722705
}
2270822706
validateLiteral(source, start = 0, end = source.length) {
@@ -22723,7 +22721,7 @@ var RegExpValidator = class {
2272322721
this.onLiteralLeave(start, end);
2272422722
}
2272522723
validateFlags(source, start = 0, end = source.length) {
22726-
const existingFlags = new Set();
22724+
const existingFlags = /* @__PURE__ */ new Set();
2272722725
let global = false;
2272822726
let ignoreCase = false;
2272922727
let multiline = false;
@@ -25812,7 +25810,7 @@ function validateObject(value, schema2, context) {
2581225810
}
2581325811
throw new Error(`Internal Error, couldn't locate key ${key}`);
2581425812
};
25815-
const inspectedProps = new Set();
25813+
const inspectedProps = /* @__PURE__ */ new Set();
2581625814
if (schema2.properties !== void 0) {
2581725815
result = context.withSchemaPath("properties", () => {
2581825816
let result2 = true;
@@ -27918,7 +27916,7 @@ var noCompletions = {
2791827916
cacheable: false
2791927917
};
2792027918
function uniqBy(lst, keyFun) {
27921-
const itemSet = new Set();
27919+
const itemSet = /* @__PURE__ */ new Set();
2792227920
return lst.filter((item) => {
2792327921
const key = keyFun(item);
2792427922
if (key === void 0) {
@@ -28001,7 +27999,7 @@ function completions(obj) {
2800127999
const key = completion.value.split(":")[0];
2800228000
const matchingSubSchemas = navigateSchemaByInstancePath(completion.schema, [key]);
2800328001
const canSuggestOnAccept = (ss) => {
28004-
const matchingTypes = new Set();
28002+
const matchingTypes = /* @__PURE__ */ new Set();
2800528003
walkSchema(ss, (s) => {
2800628004
const t = schemaType(s);
2800728005
switch (t) {
@@ -28098,7 +28096,7 @@ function completions(obj) {
2809828096
return false;
2809928097
}
2810028098
const enabled2 = formatTags.filter((tag) => !tag.startsWith("!"));
28101-
const enabledSet = new Set();
28099+
const enabledSet = /* @__PURE__ */ new Set();
2810228100
if (enabled2.length === 0) {
2810328101
for (const el of aliases["pandoc-all"]) {
2810428102
enabledSet.add(el);
@@ -28155,7 +28153,7 @@ async function automationFromGoodParseMarkdown(kind, context) {
2815528153
if (kind === "completions") {
2815628154
let foundCell = void 0;
2815728155
for (const cell of result.cells) {
28158-
const size = lines(cell.source.value).length;
28156+
const size = lines((cell.sourceWithYaml || cell.source).value).length;
2815928157
if (size + cell.cellStartLine > position.row) {
2816028158
foundCell = cell;
2816128159
break;
@@ -28374,7 +28372,7 @@ initialization does not contain language extensions`);
2837428372
}
2837528373
async function init(context) {
2837628374
const ideInit = async () => {
28377-
const resourceModule = (await Promise.resolve().then(() => __toModule(require_yaml_intelligence_resources()))).default;
28375+
const resourceModule = (await Promise.resolve().then(() => __toESM(require_yaml_intelligence_resources()))).default;
2837828376
await getTreeSitter();
2837928377
if (context.client && context.client === "lsp") {
2838028378
await initYamlIntelligence({ resourceModule, patchMarkdown: false });

0 commit comments

Comments
 (0)