Commit Graph

119 Commits

Author SHA1 Message Date
Matt Bierner
e3bc0ad257 Unregister capabilities on provider dispose
Fixes #97060
2020-05-11 11:21:39 -07:00
Matt Bierner
2a36b7d0d5 Fixing revert and close editor on reload 2020-04-30 18:01:22 -07:00
Matt Bierner
cc1e59bd70 Make sure we pass through backupId in custom editors
Fixes #96484
2020-04-29 14:06:22 -07:00
Matt Bierner
f35758ab21 Rename supportsMultipleEditorsPerResource -> supportsMultipleEditorsPerDocument
For #77131
2020-04-23 17:33:06 -07:00
Matt Bierner
5913061e1b Allow a custom editor to opt out of supporting multiple instances for a single resource
#77131
2020-04-16 17:40:20 -07:00
Matt Bierner
5426f5ff70 Add CustomDocumentContentChangeEvent
For #77131

- Rename `onDidEdit` to `onDidChange`
- Allow custom editors to fire a `CustomDocumentContentChangeEvent` that only marks the editor as dirty but does not enable undo/redo. The only way for editor to get out of this dirty state is to either save or revert the file
2020-04-16 17:40:20 -07:00
Matt Bierner
e31bbff8a8 Passing backup id through restored custom editors 2020-04-15 10:02:47 -07:00
Matt Bierner
bbb4b8e208 Try cancelling saves for custom editors if another save comes in
Fixes #93901
2020-04-13 16:07:38 -07:00
Matt Bierner
d4ce7148dd New custom editor API proposal
For #77131

Fixes #93963
Fixes #94515
Fixes #94517
Fixes #94527
Fixes #94509
Fixes #94514
Fixes #93996
Fixes #93913

This removes explicit edits from the API and reshapes the API to more closely match VS Code's internal API. The change also tries to better express the lifecycle of backups
2020-04-08 17:53:39 -07:00
Matt Bierner
8c4b52e622 Show an error message when creating a custom document fails
Fixes #93995
2020-04-02 16:49:41 -07:00
Matt Bierner
bd6ad5592f Check in saveAs cancellation 2020-04-01 17:22:37 -07:00
Matt Bierner
b8295c1a37 Try restoring the dirty state of backedup custom editors 2020-03-27 14:31:12 -07:00
Matt Bierner
c456674fb8 Fix file move for custom editors (#93059)
* Fix rename on custom editors

* - Return disposable for register call
- Use `regsiterWorkingCopyProvider` to implement basic working copy provider
- Adding test

* Update src/vs/workbench/services/workingCopy/common/workingCopyFileService.ts

Co-Authored-By: Benjamin Pasero <benjamin.pasero@gmail.com>

* Update src/vs/workbench/services/workingCopy/common/workingCopyFileService.ts

Co-Authored-By: Benjamin Pasero <benjamin.pasero@gmail.com>

* Update src/vs/workbench/services/workingCopy/common/workingCopyFileService.ts

Co-Authored-By: Benjamin Pasero <benjamin.pasero@gmail.com>

Co-authored-by: Benjamin Pasero <benjamin.pasero@gmail.com>
2020-03-27 13:01:04 -07:00
Matt Bierner
c9b48d562f Fixing save of untitled text based custom editors 2020-03-25 16:49:26 -07:00
Matt Bierner
ebb2030e1d Fixing some index bugs with edits api for custom editors 2020-03-23 14:54:47 -07:00
Matt Bierner
f05a08a624 Hook custom editors up to backup restorer (#92629)
#77131

Adds custom editor restoring to the backup restorer. This PR includes:

- Adds a `vscode-custom-editor` scheme that we use internally for custom editors. This ensures that each custom editor has it's own editing history (even if another custom editor opens the same resource).

- Make the backup restorer understand how to restore  `vscode-custom-editor` editors. This is done by adding a `IEditorInputFactoryRegistry` that lets the custom editor hook into the backup restorer
2020-03-23 13:22:30 -07:00
Matt Bierner
579dab3196 Update custom editor api
For #77131

- Use a class for `CustomDocument` instead of an interface. Extensions can now add their own data to a `CustomDocument` by sublassing

- Renamed `resolveCustomDocument` to `openCustomDocument` and require that extensions return a `CustomDocument`

- Exposed edits on `CustomDocument`

- Made the third parameter of `registerCustomEditorProvider` a generic options bag that takes a `webviewOptions`
2020-03-23 13:10:49 -07:00
Matt Bierner
7f6f3c28a6 Add cancellation parameter to custom editor resolve methods
Adds placeholder cancellation arguments to the custom editor api. These requests are currently never cancelled
2020-03-16 20:15:57 -07:00
Matt Bierner
c81074fb70 Fix webview handlers potentially not being hooked up after move 2020-03-13 17:37:11 -07:00
Matt Bierner
57278dbe4d Hook up isReadonly for custom editor input 2020-03-13 17:37:11 -07:00
Matt Bierner
89d3b684a2 Use unique resource for custom editor working copy
For #92037

Ensures that we can open multiple types of custom editors are opened for the same resource, and that our dirty tracking works as expected in that case (by only marking editors of a given type dirty)
2020-03-12 22:15:21 -07:00
Matt Bierner
8383eec1b6 Extract undo/redo 2020-03-12 20:51:19 -07:00
Matt Bierner
a79af6ef02 Make sure we localize the default label 2020-03-12 20:48:36 -07:00
Matt Bierner
9dae408dc3 Switch webview api back to use delegate model
For #77131

Going back the the delegate based model for a few reasons:

- It gives us a better approach to add additional API hooks in the future (such as for rename)

- In practive, the capabilities were almost always the same as the `userData` on the document. It is rather confusing to have both `userData` and the capabilities 'on' the document
2020-03-12 16:54:48 -07:00
Matt Bierner
3ef02fe7b0 Use the UndoRedoService for CustomEditors (#92408)
* Use the UndoRedoService for CustomEditors

For #90110

Changes custom editors (the ones not based on text) to use the UndoRedoService. This involved:

- Moving edit lifecycle back into the main process again (this is actually the bulk of the changes)
- Removing the `undo`/`redo` methods on  `CustomEditorModel`
- Using the undoRedoService to trigger undo/redo
2020-03-12 11:34:40 -07:00
Matt Bierner
077cd38d26 Add cancellation on CustomEditor.save
For #91702
2020-03-04 15:49:10 -08:00
Matt Bierner
cf086f01bd Don't send custom editor edit events to extension host for non-editable custom editors 2020-03-04 14:14:31 -08:00
Matt Bierner
466f7166b8 Move onDispose method onto webview 2020-03-04 14:14:31 -08:00
Matt Bierner
b31befa982 Fix merge conflicts 2020-03-03 22:03:58 -08:00
Jean Pierre
44d13e327a Fixes #85359 (#91830)
Co-authored-by: Matt Bierner <matb@microsoft.com>
2020-03-03 21:58:27 -08:00
Matt Bierner
3c0cc04507 💄 2020-03-03 17:12:40 -08:00
Benjamin Pasero
418d1974ca Workbench editor renames (#91943)
* IEditor => IEditorPane

* More panes:
* IVisibleEditor => IVisibleEditorPane
* ITextEditor => ITextEditorPane
* ITextDiffEditor => ITextDiffEditorPane

* imports - remove type alias

* More pane renames
* IEditorService#activeControl => activeEditorPane
* IEditorService#visibleControls => visibleEditorPanes

* More editor renames
* activeTextEditorWidget => activeTextEditorControl
* visibleTextEditorWidgets => visibleTextEditorControls
2020-03-03 10:47:50 +01:00
Matt Bierner
44c76bd3b9 Rework management of custom editor custom models
Fixes #91670

- Move model type logic out of `CustomEditorInput` and into two different implementations of `ICustomEditorModel`
- Add `CustomTextEditorModel` that owns a proper model reference to a text document. This should ensure the text document is disposed of if there are no more references to it
- Move most of the previous `CustomEditorModel` into `mainThreadWebviews` directly. This removes some of the indirection that was previously required (such as using `waitUntil`)
2020-03-02 20:27:06 -08:00
Matt Bierner
96d7905ca2 Remove unreachable code path 2020-03-02 16:20:36 -08:00
Matt Bierner
0fa3af8b60 Use es6 version of methods 2020-03-02 16:20:36 -08:00
Matt Bierner
dc68e6578e rename custom editor activation event
For #77131

Renames the activation event from `onWebviewEditor` to `onCustomEditor` to be consistent with the reset of the API
2020-02-26 10:59:36 -08:00
Matt Bierner
99d5733e5f New iteration of webview editor API proposal
For #77131

**Motivation**
While our existing webview editor API proposal more or less works, building an editable webview editor is fairly tricky using it! This is especially true for simple text based editors.

It'd also be nice if we could get bi-directional live editing for text files. For example, if I open the same file in a webview editor and in VS Code's normal editor, edits on either side should be reflected in the other. While this can sort of be implemented using the existing API, it has some big limitations

**Overview of changes**
To address these problems, we've decided have two types of webview editors:

- Text based webview editors. These editors used a `TextDocument` as their data model, which considerably simplifies implementing an editable webview. In almost all cases, this should be what you use for text files

- Complex webview editors. This is basically the existing proposed API. This gives extension hooks into all the VS Code events, such as `save`, `undo`, and so on. These should be used for binary files or in very complex text editor cases.

Both editor types now have an explicit model layer based on documents. Text editor use `TextDocument` for this, while custom editors use `WebviewEditorCustomDocument`. This replaces the delegate based approach previously used.
2020-02-21 16:26:01 -08:00
Benjamin Pasero
bde31da263 editors - getResource => resource 2020-02-18 15:53:34 +01:00
Matt Bierner
f3dbcea32a Adds a backup method (#88948)
Adds a backup method to the custom editor API proposal. This method allows custom editors to hook in to VS Code's hot exit behavior

If `backup` is not implemented, VS Code will assume that the custom editor cannot be hot exited.

When `backup` is implemented, VS Code will invoke the method after every edit (this is debounced). At this point, this extension should back up the current resource.  The result is a promise indicating if the backup was successful or not

VS Code will only hot exit if all backups were successful.
2020-01-23 16:14:27 -08:00
Matt Bierner
ff9fd2fa1a Custom Editors: pass original edit objects back to extensions
For #88719

With this change, instead of passing custom editor edit json back and forth with the extension host, we keep the original edit objects on the extension host. This means that we can pass extensions back the exact same edit object they first hand to us. It also means that edits no longer need to be json serializable.
2020-01-19 20:14:25 -08:00
Matt Bierner
5335a721fa Add backup capability for custom editors 2020-01-19 20:14:25 -08:00
Benjamin Pasero
664836ec0e debt - loadOrCreate => resolve 2020-01-16 15:39:09 +01:00
Matt Bierner
8520f74c08 Implement a default saveAs for readonly custom editors
Fixes #88414
2020-01-10 18:19:41 -08:00
Matt Bierner
b435511d7b Fixing undo/redo for new custom editor proposal 2019-12-17 15:02:36 -08:00
Matt Bierner
8e475f9b24 Implement draft 2 from #86802 (#87117) 2019-12-16 14:18:58 -08:00
Matt Bierner
d43ca55162 Move more functionality into registerCapabilities 2019-12-02 13:35:36 -08:00
Matt Bierner
e3fb9ceca1 Use single editable capability 2019-12-02 13:35:36 -08:00
Matt Bierner
e33be1b0af Explicitly register for save and saveAs 2019-12-02 13:35:35 -08:00
Johannes Rieken
a71694386d keep links from web view untouch for as long as possible, #83645 2019-11-29 15:51:44 +01:00
Matt Bierner
a8158aee89 Make sure we dispose of webviews in correct order
Fixes #85621

We must fire the the dispose event before  disposing of the event
2019-11-26 11:49:02 -08:00