CustomTextEditorProvider webviews never execute JavaScript (reproduced on 3.21.18 and 3.24.12, Windows)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Webviews hosted inside custom editors (registered via vscode.window.registerCustomEditorProvider with a CustomTextEditorProvider) never execute any JavaScript — neither inline <script> blocks nor external script files. The HTML renders, but everything script-driven stays dead.

The exact same webview HTML works perfectly inside a regular webview panel (vscode.window.createWebviewPanel) in the same Cursor instance, so the issue is specific to the custom editor hosting path.

Impact: any extension that renders its UI through a custom editor appears frozen/static in Cursor (CSV/grid editors, PDF viewers, diagram editors, …).

Steps to Reproduce

Minimal extension (~40 lines, plain JS, no frameworks):

package.json:

{
  "name": "csvtest",
  "displayName": "CSV Test Grid",
  "version": "0.0.3",
  "publisher": "wuxusgames",
  "engines": {
    "vscode": "^1.70.0"
  },
  "activationEvents": [
    "onCustomEditor:csvtest.grid"
  ],
  "main": "./out/ext.js",
  "contributes": {
    "customEditors": [
      {
        "viewType": "csvtest.grid",
        "displayName": "CSV Test Grid",
        "selector": [
          {
            "filenamePattern": "*.csvx"
          }
        ],
        "priority": "default"
      }
    ]
  }
}

out/ext.js:

const vscode = require('vscode');
const fs = require('fs');
const LOG = 'D:/csvtest-alive.log'; // any writable path
function log(m) { try { fs.appendFileSync(LOG, new Date().toISOString() + ' ' + m + ' \n'); } catch (e) {} }

function activate(context) {
  log('activate called');
  context.subscriptions.push(
    vscode.window.registerCustomEditorProvider('csvtest.grid', {
      resolveCustomTextEditor(document, panel) {
        log('resolveCustomTextEditor ' + document.uri.fsPath);
        panel.webview.onDidReceiveMessage((m) => log('webview message: ' + JSON.stringify(m)));
        panel.webview.html = '<!DOCTYPE html><html><head><meta charset='utf-8'></head>' +
          '<body style='background:#fff;color:#000;font-size:28px;padding:40px'>' +
          '<div id='s'>STATIC (no script ran)</div>' +
          '<script>' +
          '  var el = document.getElementById('s');' +
          '  try {' +
          '    var vscode = acquireVsCodeApi();' +
          '    el.innerText = 'SCRIPT RAN (api ok)';' +
          '    vscode.postMessage({ command: 'alive' });' +
          '  } catch (e) { el.innerText = 'SCRIPT RAN (api failed: ' + e + ')'; }' +
          '</script></body></html>';
      }
    }, { webviewOptions: { enableScripts: true } })
  );
}
module.exports = { activate, deactivate() {} };

Steps:

  1. Package as a vsix and install it (cursor --install-extension csvtest.vsix).
  2. Create a file test.csvx with any content.
  3. Open a new Cursor window, wait ~10 seconds (extension activation), then open test.csvx from the explorer.
  4. Observe: the tab shows STATIC (no script ran) — the inline script never executed. The log file records activate called and resolveCustomTextEditor ..., but no webview message ever arrives.

Already tried: explicit webviewOptions: { enableScripts: true } (also without it, since VS Code enables scripts implicitly for custom editors); with and without a CSP meta (script-src 'unsafe-inline'); full app restart; verified the extension activates and resolveCustomTextEditor runs. A regular createWebviewPanel panel with identical HTML works fine (scripts run, messages flow).

Expected Behavior

Per the VS Code custom editor docs, custom editor webviews should behave like normal webviews and execute scripts when enabled (this is how real VS Code behaves). In Cursor the custom editor webview stays script-less.

Operating System

Windows 10/11

Version Information

Cursor 3.24.12
Commit: 37b865941ccb31e2fc90c685157534efca87f960
x64
(also reproduced on Cursor 3.21.18, Windows 10 x64 10.0.26200)

Additional Information

Not AI-related — this is an extension-host webview issue. Happy to provide the packaged vsix or any further diagnostics if useful.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @callmewgf, thanks for the detailed repro!

This one comes down to where enableScripts is set. The webviewOptions you pass to registerCustomEditorProvider only accepts panel options (retainContextWhenHidden, enableFindWidget), so enableScripts there is ignored. Custom editor webviews start with scripts off, the same as in VS Code. createWebviewPanel works for you because it takes enableScripts directly in its options argument.

Set it on the webview itself before assigning the HTML:

resolveCustomTextEditor(document, panel) {
  panel.webview.options = { enableScripts: true };
  panel.webview.onDidReceiveMessage((m) => log('webview message: ' + JSON.stringify(m)));
  panel.webview.html = /* your HTML */;
}

After repackaging and reinstalling the vsix, the tab should show SCRIPT RAN (api ok) and your log should record the alive message.

If a published extension (a CSV or PDF viewer from the Marketplace, for example) still shows a static page after that, let us know which one and its version and we’ll take a look.