monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] Platform is not always well detected

Open CGNonofr opened this issue 1 year ago • 7 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

Since https://github.com/microsoft/vscode/pull/200935, process existing takes priority over navigator to detect is it run inside a browser. The issue is that with some bundlers like webpack, it is sometimes required to polyfill node internal (like process).

It now has as consequence to wrongly be detected as a native platform which can have consequences, for instance:

  • https://github.com/microsoft/vscode/blob/31a7befa311836b14adc6348293ad22f2257998a/src/vs/editor/browser/viewParts/lines/viewLine.ts#L23
  • https://github.com/microsoft/vscode/blob/31a7befa311836b14adc6348293ad22f2257998a/src/vs/editor/contrib/clipboard/browser/clipboard.ts#L233
  • and many more

CGNonofr avatar Feb 08 '24 17:02 CGNonofr

I've got the exact same issue, so I can't upgrade to 0.46. I used process as a fallback in my webpack.config.js and can't remove it. So my platform is not well detected.

  • With 0.45 it was web/macOs, [CORRECT]
  • With 0.46 it is native/linux. [WRONG]

boutils avatar Feb 14 '24 14:02 boutils

Indeed process.env is heavily used in A LOT of web-apps, likely the majority of them. The entire JS ecosystem is built on top of old libraries that appeared at the beginning of Node, and which require process.env to exist. Therefore web-apps which use such dependencies in the browser need to polyfill process.env.

The change in 0.46 breaks the Internet!

AurelienRibon avatar Feb 14 '24 15:02 AurelienRibon

I closed issue #4387 which I think is related to this one. For me, the problem exhibits itself in that the CtrlCmd key code does not work as it did in 0.45.0.

ben519 avatar Feb 22 '24 03:02 ben519

Oof, same issue here. No one has a workaround yet?

codebykat avatar Mar 30 '24 07:03 codebykat

Same issue here. All my keyboard shortcuts are working incorrectly on mac/chrome. Is there a workaround to manually set the platform?

Fabioni avatar Apr 05 '24 18:04 Fabioni

After upgrading to 0.48.0 it works properly for me.

rubick24 avatar May 07 '24 06:05 rubick24