Skip to content

Commit

Permalink
Properly implement onDidChangeContent (may be overridden by further r…
Browse files Browse the repository at this point in the history
…efactorings, but simple enough so implementing here for now.) Fixes #89265.
  • Loading branch information
Jackson Kearl committed Jan 27, 2020
1 parent 5a762cf commit a592b87
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchEditorInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { assertIsDefined } from 'vs/base/common/types';
import { extractSearchQuery, serializeSearchConfiguration } from 'vs/workbench/contrib/search/browser/searchEditorSerialization';
import type { ICodeEditorViewState } from 'vs/editor/common/editorCommon';
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { Emitter, Event } from 'vs/base/common/event';

export type SearchConfiguration = {
query: string,
Expand All @@ -54,6 +55,9 @@ export class SearchEditorInput extends EditorInput {
private readonly model: Promise<ITextModel>;
private query: Partial<SearchConfiguration> | undefined;

private readonly _onDidChangeContent = new Emitter<void>();
readonly onDidChangeContent: Event<void> = this._onDidChangeContent.event;

viewState: SearchEditorViewState = { focused: 'input' };

constructor(
Expand All @@ -72,15 +76,19 @@ export class SearchEditorInput extends EditorInput {
) {
super();

this.model = getModel();
this.model = getModel()
.then(model => {
this._register(model.onDidChangeContent(() => this._onDidChangeContent.fire()));
return model;
});

const input = this;
const workingCopyAdapter = new class implements IWorkingCopy {
readonly resource = input.getResource();
get name() { return input.getName(); }
readonly capabilities = input.isUntitled() ? WorkingCopyCapabilities.Untitled : 0;
readonly onDidChangeDirty = input.onDidChangeDirty;
readonly onDidChangeContent = input.onDidChangeDirty;
readonly onDidChangeContent = input.onDidChangeContent;
isDirty(): boolean { return input.isDirty(); }
backup(): Promise<IWorkingCopyBackup> { return input.backup(); }
save(options?: ISaveOptions): Promise<boolean> { return input.save(0, options).then(editor => !!editor); }
Expand Down

0 comments on commit a592b87

Please sign in to comment.