Maybe it's not a issue, more need some guides.
I'm new to Theia ide and want to get the whole or just changed document content while user click save or save all. Someone can give some hints about how to implement, thank you.
BTW: Theia version is 0.7.1.
Do you write Theia or VS Code extension?
For Theia you can look at these events: https://github.com/theia-ide/theia/blob/741876b3ecba8a968ecf1200eb231639eb3b4074/packages/monaco/src/browser/monaco-workspace.ts#L66-L79
@akosyakov Thanks for your help, using onWillSaveTextDocument works! 2 more questions:
- I have some confusion between 'open...' and 'open workspace...' items in 'File' menu, what's the difference? In frontend ui, both trigger open folders dialog, I don't know whether the backend implementation differs, could you explain a little bit.
The Open Workspace menu item in the File top-level menu is mainly used for multiple-root workspaces. It is used to select a *.theia-workspace or *.code-workspace file. When multi-root is
not enabled (preference "workspace.supportMultiRootWorkspace"), the two items behave similarly.
- If I wanna retrieve all file contents in a workspace, do you have some suggestions , I have found a "WorkspaceService" interface, there including workspace attribute or roots method pointing to the folder and files, don't know if it's the appropriate way.
The WorkspaceService can definitely be used to retrieve the workspace's root(s).
From there you can most likely use the filesystem functionality to gather all it's contents.
Most helpful comment
The
Open Workspacemenu item in theFiletop-level menu is mainly used for multiple-root workspaces. It is used to select a*.theia-workspaceor*.code-workspacefile. When multi-root isnot enabled (preference
"workspace.supportMultiRootWorkspace"), the two items behave similarly.The
WorkspaceServicecan definitely be used to retrieve the workspace's root(s).From there you can most likely use the filesystem functionality to gather all it's contents.