提交 67817c33 编写于 作者: R rebornix

fix #40713.

上级 bb8d5f18
......@@ -473,6 +473,14 @@ export class FindController extends CommonFindController implements IFindControl
this._widget = this._register(new FindWidget(this._editor, this, this._state, this._contextViewService, this._keybindingService, this._contextKeyService, this._themeService, this._storageService, this._notificationService));
this._findOptionsWidget = this._register(new FindOptionsWidget(this._editor, this._state, this._keybindingService, this._themeService));
}
saveViewState(): any {
return this._widget?.getViewState();
}
restoreViewState(state: any): void {
this._widget?.setViewState(state);
}
}
export class StartFindAction extends MultiEditorAction {
......
......@@ -582,7 +582,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
}
}
private _layoutViewZone() {
private _layoutViewZone(targetScrollTop?: number) {
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
if (!addExtraSpaceOnTop) {
......@@ -602,7 +602,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
viewZone.heightInPx = this._getHeight();
this._viewZoneId = accessor.addZone(viewZone);
// scroll top adjust to make sure the editor doesn't scroll when adding viewzone at the beginning.
this._codeEditor.setScrollTop(this._codeEditor.getScrollTop() + viewZone.heightInPx);
this._codeEditor.setScrollTop(targetScrollTop || this._codeEditor.getScrollTop() + viewZone.heightInPx);
});
}
......@@ -1266,6 +1266,29 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
const value = this._codeEditor.getOption(EditorOption.accessibilitySupport);
this._findInput.setFocusInputOnOptionClick(value !== AccessibilitySupport.Enabled);
}
getViewState() {
let widgetViewZoneVisible = false;
if (this._viewZone && this._viewZoneId) {
widgetViewZoneVisible = this._viewZone.heightInPx > this._codeEditor.getScrollTop();
}
return {
widgetViewZoneVisible,
scrollTop: this._codeEditor.getScrollTop()
};
}
setViewState(state?: { widgetViewZoneVisible: boolean; scrollTop: number }) {
if (!state) {
return;
}
if (state.widgetViewZoneVisible) {
// we should add the view zone
this._layoutViewZone(state.scrollTop);
}
}
}
export interface ISimpleButtonOpts {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册