@marimo-team/islands 0.23.7-dev50 → 0.23.7-dev51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-ui-D8ZxPNTR.js → chat-ui-DCyW3OUK.js} +2 -2
- package/dist/{code-visibility-DjsEQuRb.js → code-visibility-Cie8OiAd.js} +2 -2
- package/dist/{html-to-image-DaPPaVDP.js → html-to-image-40ZXSWP-.js} +2519 -2354
- package/dist/main.js +5 -5
- package/dist/{process-output-n0RJTxcC.js → process-output-CCeeXIBd.js} +1 -1
- package/dist/{reveal-component-pQBz0vEK.js → reveal-component-CArbt9TT.js} +2 -2
- package/package.json +1 -1
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +152 -0
- package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +99 -0
- package/src/core/codemirror/go-to-definition/commands.ts +382 -22
- package/src/core/codemirror/go-to-definition/utils.ts +23 -5
package/dist/main.js
CHANGED
|
@@ -22,18 +22,18 @@ import { _ as Logger, c as Objects, g as cn, h as Events, i as NOT_SET, l as use
|
|
|
22
22
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
23
23
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
24
24
|
import { n as Copy, r as toast, t as copyToClipboard } from "./copy-DLf4aN7I.js";
|
|
25
|
-
import { $ as useCellActions, At as DeferredRequestRegistry, B as safeExtractSetUIElementMessageBuffers, Bn as CircleAlert, Bt as getDataTypeColor, C as AccordionContent, Cn as Root2$1, Ct as customPythonLanguageSupport, Dn as Table2, Dt as Paths, E as BorderAllIcon, En as Trash2, Et as PathBuilder, F as base64ToDataView, Fn as Eye, Ft as jotaiJsonStorage, Gt as convertStatsName, H as getMarimoExportContext, J as getCellNames, Jt as useRequestClient, K as createActions, Kt as getRequestClient, L as dataViewToBase64, Ln as Database, Mn as Layers, Nn as Info, Nt as repl, On as PaintRoller, Pn as FileText, Q as reducer, Rn as Columns2, Rt as PluralWords, S as Accordion, Sn as Item$1, St as Checkbox, T as AccordionTrigger, U as hasTrustedExportContext, V as renderHTML, Vn as Braces, Vt as require_client, W as hasRunAnyCellAtom, X as notebookOutline, Y as notebookAtom, Yt as isUninstantiated, Z as numColumnsAtom, _n as atomWithStorage, a as useLastFocusedCellId, an as parseInitialValue, bt as isInternalCellName, ct as kioskModeAtom, dn as OBJECT_ID_ATTR, dt as outputIsLoading, en as NotebookScopedLocalStorage, et as useCellIds, f as isOutputEmpty, fn as RANDOM_ID_ATTR, ft as outputIsStale, gn as atomWithReducer, i as useCellFocusActions, in as parseDataset, jn as LoaderCircle, jt as generateUUID, k as ChevronDownIcon, ln as UIElementId, mt as headingToIdentifier, nt as createCell, o as maybeAddAltairImport, ot as getInitialAppMode, p as useExpandedConsoleOutput, pn as jsonParseWithSpecialChar, pt as isErrorMime, qt as requestClientAtom, r as LazyAnyLanguageCodeMirror, rn as parseAttrValue, s as Spinner, sn as HTMLCellId, st as initialModeAtom, un as findCellId, vn as selectAtom, w as AccordionItem, wn as Trigger2, wt as MarkdownLanguageAdapter, xn as Content2, xt as normalizeName, yt as getValidName, zt as DATA_TYPE_ICON, __tla as __tla_0 } from "./html-to-image-
|
|
25
|
+
import { $ as useCellActions, At as DeferredRequestRegistry, B as safeExtractSetUIElementMessageBuffers, Bn as CircleAlert, Bt as getDataTypeColor, C as AccordionContent, Cn as Root2$1, Ct as customPythonLanguageSupport, Dn as Table2, Dt as Paths, E as BorderAllIcon, En as Trash2, Et as PathBuilder, F as base64ToDataView, Fn as Eye, Ft as jotaiJsonStorage, Gt as convertStatsName, H as getMarimoExportContext, J as getCellNames, Jt as useRequestClient, K as createActions, Kt as getRequestClient, L as dataViewToBase64, Ln as Database, Mn as Layers, Nn as Info, Nt as repl, On as PaintRoller, Pn as FileText, Q as reducer, Rn as Columns2, Rt as PluralWords, S as Accordion, Sn as Item$1, St as Checkbox, T as AccordionTrigger, U as hasTrustedExportContext, V as renderHTML, Vn as Braces, Vt as require_client, W as hasRunAnyCellAtom, X as notebookOutline, Y as notebookAtom, Yt as isUninstantiated, Z as numColumnsAtom, _n as atomWithStorage, a as useLastFocusedCellId, an as parseInitialValue, bt as isInternalCellName, ct as kioskModeAtom, dn as OBJECT_ID_ATTR, dt as outputIsLoading, en as NotebookScopedLocalStorage, et as useCellIds, f as isOutputEmpty, fn as RANDOM_ID_ATTR, ft as outputIsStale, gn as atomWithReducer, i as useCellFocusActions, in as parseDataset, jn as LoaderCircle, jt as generateUUID, k as ChevronDownIcon, ln as UIElementId, mt as headingToIdentifier, nt as createCell, o as maybeAddAltairImport, ot as getInitialAppMode, p as useExpandedConsoleOutput, pn as jsonParseWithSpecialChar, pt as isErrorMime, qt as requestClientAtom, r as LazyAnyLanguageCodeMirror, rn as parseAttrValue, s as Spinner, sn as HTMLCellId, st as initialModeAtom, un as findCellId, vn as selectAtom, w as AccordionItem, wn as Trigger2, wt as MarkdownLanguageAdapter, xn as Content2, xt as normalizeName, yt as getValidName, zt as DATA_TYPE_ICON, __tla as __tla_0 } from "./html-to-image-40ZXSWP-.js";
|
|
26
26
|
import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BOg95xG5.js";
|
|
27
27
|
import { o as useSize, s as Root$2, u as createLucideIcon } from "./dist-D3ZI9nhS.js";
|
|
28
28
|
import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-hVaaZsY5.js";
|
|
29
|
-
import { $ as filtersToFilterGroup, A as contextAwarePanelOwner, At as Funnel, B as TableCell, Bt as ChevronLeft, C as prettifyRowCount, Ct as useOverflowDetection, D as ContextAwarePanelItem, Dt as EmotionCacheProvider, E as ComboboxItem, Et as HtmlOutput, F as Toggle, Ft as Code, G as generateColumns, H as TableHeader, I as Fill, It as ChevronsUpDown, J as ColumnChartContext, K as inferFieldTypes, L as Provider$1, Lt as ChevronsRight, M as isCellAwareAtom, N as SlotNames, Nt as Ellipsis, O as PANEL_TYPES, Ot as TextWrap, P as slotsController, Pt as Download, Q as usePrevious$1, R as Table, Rt as ChevronsLeft, S as prettifyRowColumnCount, St as LazyVegaEmbed, T as Combobox, Tt as Kbd, U as TableRow, V as TableHead, Vt as ArrowDownWideNarrow, W as NAMELESS_COLUMN_PREFIX, X as DelayMount, Y as ColumnChartSpecModel, Z as useIntersectionObserver, _ as downloadBlob, _t as TabsList, at as TOO_MANY_ROWS, b as Progress, bt as ChartInfoState, c as Slide, ct as Command, d as JsonOutput, dt as CommandItem, et as getPageIndexForRow, f as OutputArea, ft as CommandList, g as ADD_PRINTING_CLASS, gt as TabsContent, h as InstallPackageButton, ht as Tabs, it as SELECT_COLUMN_ID, j as contextAwarePanelType, jt as EyeOff, k as contextAwarePanelOpen, kt as GripHorizontal, l as RadioGroup, lt as CommandEmpty, m as DataTable, mt as Maps, n as marimoVersionAtom, nt as loadTableData, o as SLIDE_TYPE_OPTIONS_BY_VALUE, ot as toFieldTypes, p as OutputRenderer, pt as CommandSeparator, q as renderCellValue, r as showCodeInRunModeAtom, rt as INDEX_COLUMN_NAME, st as getMimeValues, t as useNotebookCodeAvailable, tt as loadTableAndRawData, u as RadioGroupItem, ut as CommandInput, v as downloadByURL, vt as TabsTrigger, w as useInternalStateWithSync, wt as RenderTextWithLinks, x as Filenames, xt as ChartLoadingState, y as downloadHTMLAsImage, yt as ChartErrorState, z as TableBody, zt as ChevronsDownUp, __tla as __tla_2 } from "./code-visibility-
|
|
29
|
+
import { $ as filtersToFilterGroup, A as contextAwarePanelOwner, At as Funnel, B as TableCell, Bt as ChevronLeft, C as prettifyRowCount, Ct as useOverflowDetection, D as ContextAwarePanelItem, Dt as EmotionCacheProvider, E as ComboboxItem, Et as HtmlOutput, F as Toggle, Ft as Code, G as generateColumns, H as TableHeader, I as Fill, It as ChevronsUpDown, J as ColumnChartContext, K as inferFieldTypes, L as Provider$1, Lt as ChevronsRight, M as isCellAwareAtom, N as SlotNames, Nt as Ellipsis, O as PANEL_TYPES, Ot as TextWrap, P as slotsController, Pt as Download, Q as usePrevious$1, R as Table, Rt as ChevronsLeft, S as prettifyRowColumnCount, St as LazyVegaEmbed, T as Combobox, Tt as Kbd, U as TableRow, V as TableHead, Vt as ArrowDownWideNarrow, W as NAMELESS_COLUMN_PREFIX, X as DelayMount, Y as ColumnChartSpecModel, Z as useIntersectionObserver, _ as downloadBlob, _t as TabsList, at as TOO_MANY_ROWS, b as Progress, bt as ChartInfoState, c as Slide, ct as Command, d as JsonOutput, dt as CommandItem, et as getPageIndexForRow, f as OutputArea, ft as CommandList, g as ADD_PRINTING_CLASS, gt as TabsContent, h as InstallPackageButton, ht as Tabs, it as SELECT_COLUMN_ID, j as contextAwarePanelType, jt as EyeOff, k as contextAwarePanelOpen, kt as GripHorizontal, l as RadioGroup, lt as CommandEmpty, m as DataTable, mt as Maps, n as marimoVersionAtom, nt as loadTableData, o as SLIDE_TYPE_OPTIONS_BY_VALUE, ot as toFieldTypes, p as OutputRenderer, pt as CommandSeparator, q as renderCellValue, r as showCodeInRunModeAtom, rt as INDEX_COLUMN_NAME, st as getMimeValues, t as useNotebookCodeAvailable, tt as loadTableAndRawData, u as RadioGroupItem, ut as CommandInput, v as downloadByURL, vt as TabsTrigger, w as useInternalStateWithSync, wt as RenderTextWithLinks, x as Filenames, xt as ChartLoadingState, y as downloadHTMLAsImage, yt as ChartErrorState, z as TableBody, zt as ChevronsDownUp, __tla as __tla_2 } from "./code-visibility-Cie8OiAd.js";
|
|
30
30
|
import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-BF6-z62y.js";
|
|
31
31
|
import { n as $fb18d541ea1ad717$export$ad991b66133851cf, r as $5a387cc49350e6db$export$722debc0e56fea39, t as $896ba0a80a8f4d36$export$85fd5fdf27bacc79 } from "./useDateFormatter-B_9k85Ex.js";
|
|
32
32
|
import { t as Check } from "./check-BcUIXnUT.js";
|
|
33
33
|
import { A as Trigger$1, C as $a916eb452884faea$export$b7a616150fdb9f44, D as $b5e257d569688ac6$export$535bd6ca7f90a273, E as $18f2051aff69b9bf$export$a54013f0d02a8f82, F as X, L as ChevronDown, M as usePrevious$2, N as useDirection, P as createCollection, S as logNever, T as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, a as SelectGroup, c as SelectSeparator, d as NativeSelect, f as selectStyles, i as SelectContent, j as clamp$2, k as Icon, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5, x as assertNever } from "./strings-BiIhGaI8.js";
|
|
34
34
|
import { $ as $e5be200c675c3b3a$export$aca958c65c314e6c, A as $d2b4bc8c273e7be6$export$24d547caef80ccd1, At as $c87311424ea30a05$export$fedb369cb70207f1, B as $64fa3d84918910a7$export$c62b8e45d58ddad9, Bt as $431fbd86ca7dc216$export$f21a1ffae260145a, C as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4, Ct as $8ae05eaa5c114e9c$export$7f54fc3180508a52, D as $ee014567cb39d3f0$export$ff05c3ac10437e03, Dt as $c87311424ea30a05$export$78551043582a6a98, E as $ee014567cb39d3f0$export$f551688fc98f2e09, Et as $c87311424ea30a05$export$6446a186d09e379e, F as $64fa3d84918910a7$export$2881499e37b75b9a, Ft as $d4ee10de306f2510$export$b4f377a2b6254582, H as $64fa3d84918910a7$export$ef03459518577ad4, Ht as $bdb11010cef70236$export$b4cc09c592e8fdb8, I as $64fa3d84918910a7$export$29f1550f4b0d4415, It as $d4ee10de306f2510$export$cd4e5573fbe2b576, J as $d2e8511e6f209edf$export$e908e06f4b8e3402, K as useDebounceControlledState, L as $64fa3d84918910a7$export$4d86445c2cf5e3, Lt as $d4ee10de306f2510$export$e58f029f0fbfdb29, M as $01b77f81d0f07f68$export$75b6ee27786ba447, Mt as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, N as $01b77f81d0f07f68$export$b04be29aa201d4f5, Nt as $3ef42575df84b30b$export$9d1611c77c2fe928, O as $514c0188e459b4c0$export$5f1af8db9871e1d6, Ot as $c87311424ea30a05$export$9ac100e40613ea10, P as $f39a9eba43920ace$export$b5d7cc18bb8d2b59, Pt as $d4ee10de306f2510$export$4282f70798064fe0, Q as $e5be200c675c3b3a$export$a763b9476acd3eb, R as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, Rt as $f4e2df6bd15f8569$export$98658e8c59125e6a, S as $3985021b0ad6602f$export$f5b8910cec6cf069, St as $e9faafb641e167db$export$90fc3a17d93f704c, T as $d3e0e05bdfcf66bd$export$c24727297075ec6a, Tt as $313b98861ee5dd6c$export$d6875122194c7b44, U as $64fa3d84918910a7$export$fabf2dc03a41866e, Ut as $bdb11010cef70236$export$f680877a34711e37, V as $64fa3d84918910a7$export$df3a06d6289f983e, Vt as $ff5963eb1fccf552$export$e08e3b67e392101e, Wt as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, X as $e93e671b31057976$export$b8473d3665f3a75a, Y as $2baaea4c71418dea$export$294aa081a6c6f55d, Z as $e5be200c675c3b3a$export$75ee7c75d68f5b0e, _t as $9446cca9a3875146$export$7d15b64cf5a3a4c4, a as NumberField, at as $6c7bd7858deea686$export$cd11ab140839f11d, b as DropdownMenuTrigger, bt as $b4b717babfbb907b$export$bebd5a1431fec25d, c as prettyNumber, ct as $6db58dc88e78b024$export$2f817fcdc4b89ae0, d as DropdownMenuContent, dt as $9ab94262bd0047c7$export$420e68273165f4ec, et as $e5be200c675c3b3a$export$dad6ae84456c676a, f as DropdownMenuGroup, fn as Circle, ft as $3ad3f6e1647bc98d$export$80f3e147d781571c, g as DropdownMenuSeparator, gt as $ae1eeba8b9eafd08$export$5165eccb35aaadb5, ht as _class_private_field_init, i as OnBlurredInput, it as $701a24aa0da5b062$export$ea18c227d4417cc3, j as $d2b4bc8c273e7be6$export$353f5b6fc5456de1, jt as $7215afc6de606d6b$export$de79e2c695e052f3, k as $514c0188e459b4c0$export$9afb8bc826b033ea, kt as $c87311424ea30a05$export$a11b0059900ceec8, l as prettyScientificNumber, lt as $5b160d28a433310d$export$c17fa47878dc55b6, m as DropdownMenuLabel, mt as $f6c31cce2adf654f$export$45712eceda6fad21, n as DebouncedNumberInput, nt as $319e236875307eab$export$a9b970dcc4ae71a9, ot as $fca6afa0e843324b$export$87b761675e8eaa10, p as DropdownMenuItem, pn as ChevronRight, pt as $507fabe10e71c6fb$export$630ff653c5ada6a9, q as useDebouncedCallback, r as Input, rt as $f7dceffc5ad7768b$export$4e328f61c538687f, st as $fca6afa0e843324b$export$f12b703ca79dfbb1, t as DebouncedInput, tt as $e5be200c675c3b3a$export$fc1a364ae1f3ff10, u as DropdownMenu, ut as $6179b936705e76d3$export$ae780daf29e6d456, vt as $458b0a5536c1a7cf$export$40bfa8c7b0832715, w as $a049562f99e7db0e$export$f9c6924e160136d1, wt as $df56164dff5785e2$export$4338b53315abf666, x as $3985021b0ad6602f$export$37fb8590cf2c088c, xt as $99facab73266f662$export$5add1d006293d136, yt as $b4b717babfbb907b$export$4c063cf1350e6fed, z as $64fa3d84918910a7$export$c245e6201fed2f75, zt as $431fbd86ca7dc216$export$b204af158042fbac } from "./input-D4kjoQUB.js";
|
|
35
35
|
import { _ as isWasm, c as asRemoteURL, d as isStaticNotebook, f as appendQueryParams, g as Deferred, m as require_cuid2, u as getStaticVirtualFiles, v as CircleQuestionMark } from "./toDate-CJWlVNGD.js";
|
|
36
|
-
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-
|
|
36
|
+
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-CCeeXIBd.js";
|
|
37
37
|
import { i as Pencil, n as Trash, r as Plus, t as BulkEdit } from "./types-Dzuoc3LN.js";
|
|
38
38
|
import { t as require_react_dom } from "./react-dom-BWRJ_g_k.js";
|
|
39
39
|
import { t as require_jsx_runtime } from "./jsx-runtime-COBk7ree.js";
|
|
@@ -13569,7 +13569,7 @@ let __tla = Promise.all([
|
|
|
13569
13569
|
};
|
|
13570
13570
|
}
|
|
13571
13571
|
};
|
|
13572
|
-
var LazyChatbot = import_react.lazy(() => import("./chat-ui-
|
|
13572
|
+
var LazyChatbot = import_react.lazy(() => import("./chat-ui-DCyW3OUK.js").then((e) => ({
|
|
13573
13573
|
default: e.Chatbot
|
|
13574
13574
|
}))), messageSchema = array(object({
|
|
13575
13575
|
id: string(),
|
|
@@ -44606,7 +44606,7 @@ ${c}
|
|
|
44606
44606
|
if (l && l !== "slide") return l;
|
|
44607
44607
|
if (c == null ? void 0 : c.has(e)) return "skip";
|
|
44608
44608
|
}
|
|
44609
|
-
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-
|
|
44609
|
+
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-CArbt9TT.js"));
|
|
44610
44610
|
const SlidesLayoutPlugin = {
|
|
44611
44611
|
type: "slides",
|
|
44612
44612
|
name: "Slides",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
2
2
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
3
|
-
import { it as parseHtmlContent, rt as ansiToPlainText } from "./html-to-image-
|
|
3
|
+
import { it as parseHtmlContent, rt as ansiToPlainText } from "./html-to-image-40ZXSWP-.js";
|
|
4
4
|
import { u as createLucideIcon } from "./dist-D3ZI9nhS.js";
|
|
5
5
|
import { t as Strings } from "./strings-BiIhGaI8.js";
|
|
6
6
|
import { t as require_jsx_runtime } from "./jsx-runtime-COBk7ree.js";
|
|
@@ -6,9 +6,9 @@ import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
|
6
6
|
import { _ as Logger, g as cn, h as Events, l as useEventListener, t as Button } from "./button-Dj4BTre0.js";
|
|
7
7
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
8
8
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
9
|
-
import "./html-to-image-
|
|
9
|
+
import "./html-to-image-40ZXSWP-.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-BOg95xG5.js";
|
|
11
|
-
import { Ft as Code, Mt as Expand, a as DEFAULT_SLIDE_TYPE, c as Slide, i as DEFAULT_DECK_TRANSITION, jt as EyeOff, s as SlideSidebar, t as useNotebookCodeAvailable } from "./code-visibility-
|
|
11
|
+
import { Ft as Code, Mt as Expand, a as DEFAULT_SLIDE_TYPE, c as Slide, i as DEFAULT_DECK_TRANSITION, jt as EyeOff, s as SlideSidebar, t as useNotebookCodeAvailable } from "./code-visibility-Cie8OiAd.js";
|
|
12
12
|
import "./input-D4kjoQUB.js";
|
|
13
13
|
import "./toDate-CJWlVNGD.js";
|
|
14
14
|
import "./react-dom-BWRJ_g_k.js";
|
package/package.json
CHANGED
|
@@ -101,6 +101,158 @@ print(x)`);
|
|
|
101
101
|
`);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
test("selects the nearest in-scope local definition", async () => {
|
|
105
|
+
const code = `\
|
|
106
|
+
a = 10
|
|
107
|
+
|
|
108
|
+
def my_func():
|
|
109
|
+
a = 20
|
|
110
|
+
print(a)`;
|
|
111
|
+
view = createEditor(code);
|
|
112
|
+
const result = goToVariableDefinition(view, "a", code.lastIndexOf("a"));
|
|
113
|
+
|
|
114
|
+
expect(result).toBe(true);
|
|
115
|
+
await tick();
|
|
116
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
117
|
+
"
|
|
118
|
+
a = 10
|
|
119
|
+
|
|
120
|
+
def my_func():
|
|
121
|
+
a = 20
|
|
122
|
+
^
|
|
123
|
+
print(a)
|
|
124
|
+
"
|
|
125
|
+
`);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("selects the nearest in-scope parameter definition", async () => {
|
|
129
|
+
const code = `\
|
|
130
|
+
a = 10
|
|
131
|
+
|
|
132
|
+
def my_func(a):
|
|
133
|
+
print(a)`;
|
|
134
|
+
view = createEditor(code);
|
|
135
|
+
const result = goToVariableDefinition(view, "a", code.lastIndexOf("a"));
|
|
136
|
+
|
|
137
|
+
expect(result).toBe(true);
|
|
138
|
+
await tick();
|
|
139
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
140
|
+
"
|
|
141
|
+
a = 10
|
|
142
|
+
|
|
143
|
+
def my_func(a):
|
|
144
|
+
^
|
|
145
|
+
print(a)
|
|
146
|
+
"
|
|
147
|
+
`);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("selects the comprehension target inside a set comprehension", async () => {
|
|
151
|
+
const code = `\
|
|
152
|
+
x = 100
|
|
153
|
+
s = {x for x in range(10)}`;
|
|
154
|
+
view = createEditor(code);
|
|
155
|
+
// Go-to-definition on the `x` before `for` (the expression part of the
|
|
156
|
+
// comprehension).
|
|
157
|
+
const usagePosition = code.indexOf("{x") + 1;
|
|
158
|
+
const result = goToVariableDefinition(view, "x", usagePosition);
|
|
159
|
+
|
|
160
|
+
expect(result).toBe(true);
|
|
161
|
+
await tick();
|
|
162
|
+
// Should jump to the comprehension target `x` (after `for`), not the
|
|
163
|
+
// outer `x = 100`. The Lezer Python grammar emits
|
|
164
|
+
// `SetComprehensionExpression`, and we now correctly match it in
|
|
165
|
+
// SCOPE_CREATING_NODES, so the comprehension creates a scope and the
|
|
166
|
+
// for-target is collected correctly.
|
|
167
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
168
|
+
"
|
|
169
|
+
x = 100
|
|
170
|
+
s = {x for x in range(10)}
|
|
171
|
+
^
|
|
172
|
+
"
|
|
173
|
+
`);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("selects the comprehension target inside a dict comprehension", async () => {
|
|
177
|
+
const code = `\
|
|
178
|
+
x = 100
|
|
179
|
+
d = {x: x for x in range(10)}`;
|
|
180
|
+
view = createEditor(code);
|
|
181
|
+
const usagePosition = code.indexOf("{x") + 1;
|
|
182
|
+
const result = goToVariableDefinition(view, "x", usagePosition);
|
|
183
|
+
|
|
184
|
+
expect(result).toBe(true);
|
|
185
|
+
await tick();
|
|
186
|
+
// Positive control: `DictionaryComprehensionExpression` matches the grammar
|
|
187
|
+
// and is in SCOPE_CREATING_NODES, so this should jump to the comprehension
|
|
188
|
+
// target `x` (after `for`).
|
|
189
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
190
|
+
"
|
|
191
|
+
x = 100
|
|
192
|
+
d = {x: x for x in range(10)}
|
|
193
|
+
^
|
|
194
|
+
"
|
|
195
|
+
`);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("skips enclosing class scope when resolving from inside a method", async () => {
|
|
199
|
+
const code = `\
|
|
200
|
+
x = 100
|
|
201
|
+
class Foo:
|
|
202
|
+
x = 10
|
|
203
|
+
def method(self):
|
|
204
|
+
return x`;
|
|
205
|
+
view = createEditor(code);
|
|
206
|
+
// Go-to-definition on the `x` inside `return x`.
|
|
207
|
+
const usagePosition = code.lastIndexOf("x");
|
|
208
|
+
const result = goToVariableDefinition(view, "x", usagePosition);
|
|
209
|
+
|
|
210
|
+
expect(result).toBe(true);
|
|
211
|
+
await tick();
|
|
212
|
+
// Should jump to `x = 100` at module scope. In Python, methods do NOT see
|
|
213
|
+
// their enclosing class body's names — class scopes are skipped in LEGB
|
|
214
|
+
// lookup once a function boundary has been crossed. We now correctly skip
|
|
215
|
+
// ClassDefinition in getScopeChain once a function boundary is crossed.
|
|
216
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
217
|
+
"
|
|
218
|
+
x = 100
|
|
219
|
+
^
|
|
220
|
+
class Foo:
|
|
221
|
+
x = 10
|
|
222
|
+
def method(self):
|
|
223
|
+
return x
|
|
224
|
+
"
|
|
225
|
+
`);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("resolves a global forward-reference from inside a function", async () => {
|
|
229
|
+
const code = `\
|
|
230
|
+
def foo():
|
|
231
|
+
return a
|
|
232
|
+
|
|
233
|
+
a = 10`;
|
|
234
|
+
view = createEditor(code);
|
|
235
|
+
// Go-to-definition on the `a` inside `return a`.
|
|
236
|
+
const usagePosition = code.indexOf("return a") + "return ".length;
|
|
237
|
+
const result = goToVariableDefinition(view, "a", usagePosition);
|
|
238
|
+
|
|
239
|
+
expect(result).toBe(true);
|
|
240
|
+
await tick();
|
|
241
|
+
// Should jump to `a = 10` at the bottom. Python allows forward references
|
|
242
|
+
// from within nested functions to module-level names. We now correctly omit
|
|
243
|
+
// "global" from POSITION_SENSITIVE_SCOPES, allowing forward references to
|
|
244
|
+
// global-level definitions declared after the usage position.
|
|
245
|
+
expect(renderEditorView(view)).toMatchInlineSnapshot(`
|
|
246
|
+
"
|
|
247
|
+
def foo():
|
|
248
|
+
return a
|
|
249
|
+
|
|
250
|
+
a = 10
|
|
251
|
+
^
|
|
252
|
+
"
|
|
253
|
+
`);
|
|
254
|
+
});
|
|
255
|
+
|
|
104
256
|
test("selects outer-scope function declaration", async () => {
|
|
105
257
|
view = createEditor(`\
|
|
106
258
|
def x():
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { python } from "@codemirror/lang-python";
|
|
4
|
+
import { EditorState } from "@codemirror/state";
|
|
5
|
+
import { EditorView } from "@codemirror/view";
|
|
6
|
+
import { afterEach, describe, expect, test } from "vitest";
|
|
7
|
+
import { cellId, variableName } from "@/__tests__/branded";
|
|
8
|
+
import { initialNotebookState, notebookAtom } from "@/core/cells/cells";
|
|
9
|
+
import { store } from "@/core/state/jotai";
|
|
10
|
+
import { variablesAtom } from "@/core/variables/state";
|
|
11
|
+
import { goToDefinitionAtCursorPosition } from "../utils";
|
|
12
|
+
|
|
13
|
+
async function tick(): Promise<void> {
|
|
14
|
+
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createEditor(content: string, selection: number) {
|
|
18
|
+
const state = EditorState.create({
|
|
19
|
+
doc: content,
|
|
20
|
+
selection: { anchor: selection },
|
|
21
|
+
extensions: [python()],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return new EditorView({
|
|
25
|
+
state,
|
|
26
|
+
parent: document.body,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const views: EditorView[] = [];
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
for (const view of views.splice(0)) {
|
|
34
|
+
view.destroy();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
store.set(notebookAtom, initialNotebookState());
|
|
38
|
+
store.set(variablesAtom, {});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("goToDefinitionAtCursorPosition", () => {
|
|
42
|
+
test("prefers the current-cell local definition over a reactive global", async () => {
|
|
43
|
+
const globalCell = cellId("global-cell");
|
|
44
|
+
const localCell = cellId("local-cell");
|
|
45
|
+
const globalCode = `\
|
|
46
|
+
a = 10
|
|
47
|
+
print(a)`;
|
|
48
|
+
const localCode = `\
|
|
49
|
+
def test():
|
|
50
|
+
a = 20
|
|
51
|
+
print(a)`;
|
|
52
|
+
|
|
53
|
+
const globalView = createEditor(globalCode, globalCode.length);
|
|
54
|
+
const localView = createEditor(localCode, localCode.lastIndexOf("a"));
|
|
55
|
+
views.push(globalView, localView);
|
|
56
|
+
|
|
57
|
+
const notebook = initialNotebookState();
|
|
58
|
+
notebook.cellHandles[globalCell] = {
|
|
59
|
+
current: { editorView: globalView, editorViewOrNull: globalView },
|
|
60
|
+
};
|
|
61
|
+
notebook.cellHandles[localCell] = {
|
|
62
|
+
current: { editorView: localView, editorViewOrNull: localView },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
store.set(notebookAtom, notebook);
|
|
66
|
+
store.set(variablesAtom, {
|
|
67
|
+
[variableName("a")]: {
|
|
68
|
+
dataType: "int",
|
|
69
|
+
declaredBy: [globalCell],
|
|
70
|
+
name: variableName("a"),
|
|
71
|
+
usedBy: [localCell],
|
|
72
|
+
value: "10",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const result = goToDefinitionAtCursorPosition(localView);
|
|
77
|
+
|
|
78
|
+
expect(result).toBe(true);
|
|
79
|
+
await tick();
|
|
80
|
+
expect(localView.state.selection.main.head).toBe(
|
|
81
|
+
localCode.indexOf("a = 20"),
|
|
82
|
+
);
|
|
83
|
+
expect(globalView.state.selection.main.head).toBe(globalCode.length);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("keeps private variables within the current cell", async () => {
|
|
87
|
+
const code = `\
|
|
88
|
+
_x = 10
|
|
89
|
+
output = _x + 10`;
|
|
90
|
+
const view = createEditor(code, code.lastIndexOf("_x"));
|
|
91
|
+
views.push(view);
|
|
92
|
+
|
|
93
|
+
const result = goToDefinitionAtCursorPosition(view);
|
|
94
|
+
|
|
95
|
+
expect(result).toBe(true);
|
|
96
|
+
await tick();
|
|
97
|
+
expect(view.state.selection.main.head).toBe(code.indexOf("_x = 10"));
|
|
98
|
+
});
|
|
99
|
+
});
|