Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[json] ERROR onWillSave listeners should provide edits, not directly alter the document when saving editor #6520

Open
kittaakos opened this issue Nov 9, 2019 · 3 comments
Labels
bug bugs found in the application monaco issues related to monaco

Comments

@kittaakos
Copy link
Contributor

Description

I get this error each time I save a JSON file:

logger-protocol.ts:112 root ERROR onWillSave listeners should provide edits, not directly alter the document.
log @ logger-protocol.ts:112
(anonymous) @ logger-frontend-module.ts:41
(anonymous) @ logger.ts:312
(anonymous) @ logger.ts:304
Promise.then (async)
../../packages/core/lib/common/logger.js.Logger.log @ logger.ts:299
log @ logger.ts:45
(anonymous) @ monaco-editor-model.js:534
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
fulfilled @ monaco-editor-model.js:30
Promise.then (async)
step @ monaco-editor-model.js:32
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:494
(anonymous) @ event.ts:232
step @ event.ts:15
(anonymous) @ event.ts:15
fulfilled @ event.ts:15
Promise.then (async)
step @ event.ts:15
(anonymous) @ event.ts:15
../../packages/core/lib/common/event.js.__awaiter @ event.ts:15
../../packages/core/lib/common/event.js.Emitter.sequence @ event.ts:229
(anonymous) @ monaco-editor-model.js:494
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.fireWillSaveModel @ monaco-editor-model.js:488
(anonymous) @ monaco-editor-model.js:463
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.doSave @ monaco-editor-model.js:455
(anonymous) @ monaco-editor-model.js:404
(anonymous) @ monaco-editor-model.js:298
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:292
Promise.then (async)
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.run @ monaco-editor-model.js:292
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.scheduleSave @ monaco-editor-model.js:404
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.save @ monaco-editor-model.js:288
(anonymous) @ saveable.ts:69
step @ saveable.ts:15
(anonymous) @ saveable.ts:15
(anonymous) @ saveable.ts:15
../../packages/core/lib/browser/saveable.js.__awaiter @ saveable.ts:15
save @ saveable.ts:66
(anonymous) @ application-shell.ts:1499
step @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.__awaiter @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.ApplicationShell.save @ application-shell.ts:1498
execute @ common-frontend-contribution.ts:498
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.tryKeybindingExecution @ keybinding.ts:576
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.run @ keybinding.ts:625
(anonymous) @ frontend-application.ts:170
logger-protocol.ts:112 root ERROR onWillSave listeners should provide edits, not directly alter the document.
log @ logger-protocol.ts:112
(anonymous) @ logger-frontend-module.ts:41
(anonymous) @ logger.ts:312
(anonymous) @ logger.ts:304
Promise.then (async)
../../packages/core/lib/common/logger.js.Logger.log @ logger.ts:299
log @ logger.ts:45
(anonymous) @ monaco-editor-model.js:534
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
fulfilled @ monaco-editor-model.js:30
Promise.then (async)
step @ monaco-editor-model.js:32
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:494
(anonymous) @ event.ts:232
step @ event.ts:15
(anonymous) @ event.ts:15
fulfilled @ event.ts:15
Promise.then (async)
step @ event.ts:15
(anonymous) @ event.ts:15
../../packages/core/lib/common/event.js.__awaiter @ event.ts:15
../../packages/core/lib/common/event.js.Emitter.sequence @ event.ts:229
(anonymous) @ monaco-editor-model.js:494
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.fireWillSaveModel @ monaco-editor-model.js:488
(anonymous) @ monaco-editor-model.js:463
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.doSave @ monaco-editor-model.js:455
(anonymous) @ monaco-editor-model.js:404
(anonymous) @ monaco-editor-model.js:298
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:292
Promise.then (async)
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.run @ monaco-editor-model.js:292
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.scheduleSave @ monaco-editor-model.js:404
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.save @ monaco-editor-model.js:288
(anonymous) @ saveable.ts:69
step @ saveable.ts:15
(anonymous) @ saveable.ts:15
(anonymous) @ saveable.ts:15
../../packages/core/lib/browser/saveable.js.__awaiter @ saveable.ts:15
save @ saveable.ts:66
(anonymous) @ application-shell.ts:1499
step @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.__awaiter @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.ApplicationShell.save @ application-shell.ts:1498
execute @ common-frontend-contribution.ts:498
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.tryKeybindingExecution @ keybinding.ts:576
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.run @ keybinding.ts:625
(anonymous) @ frontend-application.ts:170
logger-protocol.ts:112 root ERROR onWillSave listeners should provide edits, not directly alter the document.
log @ logger-protocol.ts:112
(anonymous) @ logger-frontend-module.ts:41
(anonymous) @ logger.ts:312
(anonymous) @ logger.ts:304
Promise.then (async)
../../packages/core/lib/common/logger.js.Logger.log @ logger.ts:299
log @ logger.ts:45
(anonymous) @ monaco-editor-model.js:534
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
fulfilled @ monaco-editor-model.js:30
Promise.then (async)
step @ monaco-editor-model.js:32
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:494
(anonymous) @ event.ts:232
step @ event.ts:15
(anonymous) @ event.ts:15
fulfilled @ event.ts:15
Promise.then (async)
step @ event.ts:15
(anonymous) @ event.ts:15
../../packages/core/lib/common/event.js.__awaiter @ event.ts:15
../../packages/core/lib/common/event.js.Emitter.sequence @ event.ts:229
(anonymous) @ monaco-editor-model.js:494
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.fireWillSaveModel @ monaco-editor-model.js:488
(anonymous) @ monaco-editor-model.js:463
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.doSave @ monaco-editor-model.js:455
(anonymous) @ monaco-editor-model.js:404
(anonymous) @ monaco-editor-model.js:298
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:292
Promise.then (async)
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.run @ monaco-editor-model.js:292
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.scheduleSave @ monaco-editor-model.js:404
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.save @ monaco-editor-model.js:288
(anonymous) @ saveable.ts:69
step @ saveable.ts:15
(anonymous) @ saveable.ts:15
(anonymous) @ saveable.ts:15
../../packages/core/lib/browser/saveable.js.__awaiter @ saveable.ts:15
save @ saveable.ts:66
(anonymous) @ application-shell.ts:1499
step @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.__awaiter @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.ApplicationShell.save @ application-shell.ts:1498
execute @ common-frontend-contribution.ts:498
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.tryKeybindingExecution @ keybinding.ts:576
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.run @ keybinding.ts:625
(anonymous) @ frontend-application.ts:170

Reproduction Steps

  • Start Theia from the source. I used the electron example.
  • Open a JSON file, modify it and then save it. My workspace was theia.

OS and Theia version:
macOS 10.14.6
2f3b2c3

Diagnostics:

@akosyakov akosyakov added bug bugs found in the application json issues related to the json language labels Nov 9, 2019
@vince-fugnitto
Copy link
Member

@kittaakos the error comes from the editor.formatOnSave preference and command.
From the initial pull request, I was getting the error message: #4012 (comment).
I also verified by turning the preference on/off.

Screen Shot 2019-11-09 at 8 47 18 AM

cc @lmcbout

@datou0412
Copy link
Contributor

Its not about .json file, .js or .xml file will reproduce this error, when editor.formatOnSave is true

@akosyakov
Copy link
Member

Yes, we should rewrite it by removing calling a command and hooking deeper into Monaco to get actual edits.

@akosyakov akosyakov added monaco issues related to monaco and removed json issues related to the json language labels Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application monaco issues related to monaco
Projects
None yet
Development

No branches or pull requests

4 participants