Skip to content

Search editor: investigate to use file working copies #118947

Closed
@bpasero

Description

@bpasero

In the context of #117873 I was doing a quick research how working copy providers that are text file model based are implemented today and found 2 examples:

  • custom text based editors
  • search editors

When you look at CustomTextEditorModel you can see how every IO related method (like save or revert) is going into the manager of text file models, e.g.:

return this.textFileService.save(this.resource, options);

This has the advantage that a lot of corner cases for saving are being taken care of that prevent data loss or corruption.

When looking at search editors, I see that a (code editor) model is being resolved or created here:

const model = this.modelService.getModel(this.modelUri) ?? this.modelService.createModel(contents, this.modeService.create('search-result'), this.modelUri);

But the IO logic is all implemented custom, e.g.:

await this.textFileService.write(this.backingUri, await this.serializeForDisk(), options);

As such, your custom search editor is a good candidate for adopting the text file model approach, similar to custom text editors.

I am inclined to mark this important because I think you really should not implement the IO logic yourself, but maybe there are no issues with your implementation either, so I leave it as debt.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions