Skip to content

Notebook-wide find, and escaped characters in saved notebooks defeat workspace search #118

Closed

Description

@mna-intend

Description

Searching a notebook does not work from either direction. Both directions work in Polyglot Notebooks and in .ipynb, so this is a regression for anyone moving to .verso.

Why it differs

Polyglot Notebooks registers its editor through VS Code's notebook API:

"contributes": { "notebooks": [ { "type": "polyglot-notebook",
                                  "selector": [ { "filenamePattern": "*.dib" } ] } ] }

.ipynb is registered the same way by VS Code's own built-in extension (notebook type "jupyter-notebook").

Verso registers a custom editor instead, and contributes no notebooks:

"contributes": { "customEditors": [ { "viewType": "verso.blazorNotebook",
                                      "selector": [ { "filenamePattern": "*.verso" },
                                                    { "filenamePattern": "*.ipynb" },
                                                    { "filenamePattern": "*.dib" } ],
                                      "priority": "default" } ] }

A custom editor is an opaque webview. VS Code cannot see the cells, so the notebook find widget, notebook-aware workspace search, outline and go-to all stop applying. Because the selector also claims *.ipynb and *.dib at default priority, installing Verso removes those features from notebooks that had them.

Symptom 1: no find inside the notebook

Each cell is a separate Monaco instance, so Ctrl+F opens Monaco's find widget scoped to the focused cell. A string in any other cell is not found. There is no notebook-wide alternative: the extension contributes three commands (verso.newNotebook, verso.compareWithBaseline, verso.openInVerso) and no keybindings, and there is no find implementation in dist/extension.js, wwwroot/js/vscode-bridge.js or monaco-interop.js.

In a .dib or .ipynb, Ctrl+F searches every cell of the notebook.

Symptom 2: workspace search cannot match the file either

Ctrl+Shift+F falls back to the raw bytes of the .verso, and the serializer escapes them. In one 3185-byte notebook here:

\u0022    26 occurrences   (")
\u002B     7 occurrences   (+)
\u003E     2 occurrences   (>)
\u003C     1 occurrence    (<)

Non-ASCII is escaped the same way, so German text in a markdown cell is unsearchable too.

The notebook contains

#r "nuget: Example.PackageA, 1.2.3"

and the file contains

"source": "#r \u0022nuget: Example.PackageA, 1.2.3\u0022\n..."

so a workspace search for #r "nuget: returns nothing.

A cell's whole source is also a single JSON string on one physical line - the longest line in that small file is 1003 characters - so even when a search term happens to contain no escaped character, the hit's line and column say nothing about where it is in the notebook, and the preview in the search results is one unreadable 1000-character line.

Expected

What the notebook API already provides: find across all cells of the open notebook, and workspace search that reports a hit as a cell of a notebook.

Suggested fix

Registering the editor through the notebook API (a NotebookSerializer, with the Blazor webview kept as the renderer where it is needed) restores both at once, plus outline, go-to-line and notebook diffs, and costs nothing in rendering.

If the custom editor has to stay, then two separate changes are needed:

  • a notebook-wide find command with a keybinding;
  • serialize with System.Text.Json's JavaScriptEncoder.UnsafeRelaxedJsonEscaping, so the file stays greppable. Writing each source line as its own array element the way .ipynb does would additionally give usable line numbers and readable diffs - a .verso change currently shows up in review as one modified 1000-character line per edited cell.

Steps to Reproduce

Inside the notebook:

  1. Open a .verso with several cells.
  2. Put the cursor in one cell, press Ctrl+F, search for a string that exists in
    a different cell.
    -> no match. The find widget belongs to that one cell.
  3. Do the same in a .dib opened with Polyglot Notebooks, or in an .ipynb:
    Ctrl+F finds the string in any cell.

From the workspace:

  1. Put this line in a cell and save: #r "nuget: Newtonsoft.Json, 13.0.3"
  2. Close the notebook, press Ctrl+Shift+F, search for: #r "nuget:
    -> no match. The file holds #r \u0022nuget:
  3. Open the .verso in a text editor: each cell's entire source is one physical
    line.

Error Output

No error. Search silently returns no results.

Component

VS Code Extension

Frontend

VS Code

Verso Version

1.2.2

.NET Version

10.0.301

Operating System

Windows 11

Notebook Snippet

// Cell 1 - put the cursor here, press Ctrl+F and search for: find-me
#r "nuget: Newtonsoft.Json, 13.0.3"

// Cell 2
var marker = "find-me";

Loaded Extensions

none

Severity

High - blocks a workflow, no reasonable workaround

Checklist

  • I searched existing issues and this hasn't been reported yet
  • I can reproduce this with no third-party extensions loaded

Activity

  1. added
    bug
    on Oct 3, 2026
  2. added
    enhancement
    and removed
    bug
    on Oct 4, 2026
  3. changed the title [-][Bug]: No notebook-wide search: the custom editor hides cells from VS Code, and the on-disk format defeats workspace search[/-] [+]Notebook-wide find, and escaped characters in saved notebooks defeat workspace search[/+] on Oct 4, 2026
  4. TorreyBetts commented on Oct 4, 2026

    @TorreyBetts
    Contributor

    Thanks for the detailed write-up, especially the byte counts and the #r "nuget: example. I've relabeled this as an enhancement and split it up a bit, since a few different things are going on.

    The escaping was a real problem, and #120 fixes it. Saved .verso and .ipynb files now keep quotes, +, <, > and non-ASCII text as they are, so a workspace search for #r "nuget: or for German markdown works. Older files still open fine and get rewritten in the new form the next time they're saved. Emoji are the one exception and are still escaped.

    I'm not planning to move Verso onto VS Code's built-in notebook editor. The custom editor is what lets Verso run the same UI in VS Code and in verso serve, and it's also what layouts, dashboards and custom cell types depend on. So that change would cost a lot more than the rendering. A find bar that searches every cell is a fair ask, though, and building it into Verso's own editor means both VS Code and the browser get it. I'll keep this issue open for that.

    If you want the built-in editor for .ipynb or .dib files in the meantime, right-click the tab and choose Reopen Editor With.

  5. mna-intend commented on Oct 19, 2026

    @mna-intend
    Author

    The escaping fix landed in 1.2.3 and works - a workspace search for #r "nuget:
    finds cell contents now, which was the bigger half of this. Thanks.

    Two things are still open, and I'm not sure the close was meant to cover them:

    The find bar you called a fair ask isn't in 1.2.3. Ctrl+F inside a cell works,
    but there's still nothing that searches the whole notebook. Was this closed
    deliberately, or should the find bar get its own issue?

    The other half is the one you already answered: a workspace search result now
    shows the matching line, and clicking it does open the notebook - it just opens
    at the top, with no indication of which cell the match was in. As I understand it
    that's inherent to the custom editor, since VS Code can only reveal a range in a
    text editor, and your reasoning for keeping the custom editor makes sense to me.
    I mention it because it's what makes the find bar more than a convenience: today
    the workspace search can tell you which file a string is in, and from there the
    only way to the cell is reading the file outside the editor.

    @TorreyBetts FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions