Improves observable descriptions

This commit is contained in:
Henning Dieterichs
2023-11-07 15:45:46 +01:00
committed by Henning Dieterichs
parent d700c43194
commit 35be92193f
7 changed files with 16 additions and 14 deletions
@@ -41,7 +41,7 @@ export class DiffEditorEditors extends Disposable {
this.original = this._register(this._createLeftHandSideEditor(_options.editorOptions.get(), codeEditorWidgetOptions.originalEditor || {}));
this.modified = this._register(this._createRightHandSideEditor(_options.editorOptions.get(), codeEditorWidgetOptions.modifiedEditor || {}));
this.modifiedModel = observableFromEvent(this.modified.onDidChangeModel, () => this.modified.getModel());
this.modifiedModel = observableFromEvent(this.modified.onDidChangeModel, () => /** @description modified.model */ this.modified.getModel());
this._register(autorunHandleChanges({
createEmptyChangeSummary: () => ({} as IDiffEditorConstructionOptions),
@@ -43,7 +43,7 @@ export class DiffEditorSash extends Disposable {
this._register(this._sash.onDidReset(() => this._sashRatio.set(undefined, undefined)));
this._register(autorun(reader => {
/** @description update sash layout */
/** @description DiffEditorSash.layoutSash */
const enabled = this._options.enableSplitViewResizing.read(reader);
this._sash.state = enabled ? SashState.Enabled : SashState.Disabled;
this.sashLeft.read(reader);
@@ -221,6 +221,7 @@ export class DiffEditorViewModel extends Disposable implements IDiffEditorViewMo
result = applyModifiedEdits(result, modifiedTextEditInfos, model.original, model.modified) ?? result;
transaction(tx => {
/** @description write diff result */
updateUnchangedRegions(result, tx);
this._lastDiff = result;
@@ -72,8 +72,8 @@ export class MovedBlocksLinesPart extends Disposable {
}));
});
this._register(applyViewZones(this._editors.original, movedBlockViewZones.map(zones => zones.map(z => z.original))));
this._register(applyViewZones(this._editors.modified, movedBlockViewZones.map(zones => zones.map(z => z.modified))));
this._register(applyViewZones(this._editors.original, movedBlockViewZones.map(zones => /** @description movedBlockViewZones.original */ zones.map(z => z.original))));
this._register(applyViewZones(this._editors.modified, movedBlockViewZones.map(zones => /** @description movedBlockViewZones.modified */ zones.map(z => z.modified))));
this._register(autorunWithStore((reader, store) => {
const blocks = movedBlockViewZones.read(reader);
@@ -104,6 +104,7 @@ export class MovedBlocksLinesPart extends Disposable {
return true;
}
}, reader => {
/** @description MovedBlocksLines.setActiveMovedTextFromCursor */
originalHasFocus.read(reader);
modifiedHasFocus.read(reader);
@@ -34,7 +34,7 @@ export interface IGhostTextWidgetModel {
export class GhostTextWidget extends Disposable {
private readonly isDisposed = observableValue(this, false);
private readonly currentTextModel = observableFromEvent(this.editor.onDidChangeModel, () => this.editor.getModel());
private readonly currentTextModel = observableFromEvent(this.editor.onDidChangeModel, () => /** @description editor.model */ this.editor.getModel());
constructor(
private readonly editor: ICodeEditor,
@@ -46,7 +46,7 @@ export class InlineCompletionsController extends Disposable {
(tx) => this.updateObservables(tx, VersionIdChangeReason.Other),
(item) => {
transaction(tx => {
/** @description handleSuggestAccepted */
/** @description InlineCompletionsController.handleSuggestAccepted */
this.updateObservables(tx, VersionIdChangeReason.Other);
this.model.get()?.handleSuggestAccepted(item);
});
@@ -83,7 +83,7 @@ export class InlineCompletionsController extends Disposable {
this._register(new InlineCompletionContextKeys(this._contextKeyService, this.model));
this._register(Event.runAndSubscribe(editor.onDidChangeModel, () => transaction(tx => {
/** @description onDidChangeModel */
/** @description InlineCompletionsController.onDidChangeModel */
this.model.set(undefined, tx);
this.updateObservables(tx, VersionIdChangeReason.Other);
@@ -112,12 +112,12 @@ export class InlineCompletionsController extends Disposable {
return VersionIdChangeReason.Other;
};
this._register(editor.onDidChangeModelContent((e) => transaction(tx =>
/** @description onDidChangeModelContent */
/** @description InlineCompletionsController.onDidChangeModelContent */
this.updateObservables(tx, getReason(e))
)));
this._register(editor.onDidChangeCursorPosition(e => transaction(tx => {
/** @description onDidChangeCursorPosition */
/** @description InlineCompletionsController.onDidChangeCursorPosition */
this.updateObservables(tx, VersionIdChangeReason.Other);
if (e.reason === CursorChangeReason.Explicit || e.source === 'api') {
this.model.get()?.stop(tx);
@@ -125,7 +125,7 @@ export class InlineCompletionsController extends Disposable {
})));
this._register(editor.onDidType(() => transaction(tx => {
/** @description onDidType */
/** @description InlineCompletionsController.onDidType */
this.updateObservables(tx, VersionIdChangeReason.Other);
if (this._enabled.get()) {
this.model.get()?.trigger(tx);
@@ -159,13 +159,13 @@ export class InlineCompletionsController extends Disposable {
return;
}
transaction(tx => {
/** @description onDidBlurEditorWidget */
/** @description InlineCompletionsController.onDidBlurEditorWidget */
this.model.get()?.stop(tx);
});
}));
this._register(autorun(reader => {
/** @description forceRenderingAbove */
/** @description InlineCompletionsController.forceRenderingAbove */
const state = this.model.read(reader)?.state.read(reader);
if (state?.suggestItem) {
if (state.ghostText.lineCount >= 2) {
@@ -188,7 +188,7 @@ export class InlineCompletionsController extends Disposable {
return true;
},
}, async reader => {
/** @description play audio cue & read suggestion */
/** @description InlineCompletionsController.playAudioCueAndReadSuggestion */
this._playAudioCueSignal.read(reader);
const model = this.model.read(reader);
@@ -43,7 +43,7 @@ class DiffEditorHelperContribution extends Disposable implements IDiffEditorCont
const isEmbeddedDiffEditor = this._diffEditor instanceof EmbeddedDiffEditorWidget;
if (!isEmbeddedDiffEditor) {
const computationResult = observableFromEvent(e => this._diffEditor.onDidUpdateDiff(e), () => this._diffEditor.getDiffComputationResult());
const computationResult = observableFromEvent(e => this._diffEditor.onDidUpdateDiff(e), () => /** diffEditor.diffComputationResult */ this._diffEditor.getDiffComputationResult());
const onlyWhiteSpaceChange = computationResult.map(r => r && !r.identical && r.changes2.length === 0);
this._register(autorunWithStore((reader, store) => {