Skip to content

Commit 28a506b

Browse files
author
Akos Kitta
committed
Do not start tasks to reset scroll in pref editor.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 00959d2 commit 28a506b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ import { StatusBarImpl } from './theia/core/status-bar';
323323
import { StatusBarImpl as TheiaStatusBarImpl } from '@theia/core/lib/browser';
324324
import { EditorMenuContribution } from './theia/editor/editor-file';
325325
import { EditorMenuContribution as TheiaEditorMenuContribution } from '@theia/editor/lib/browser/editor-menu';
326+
import { PreferencesEditorWidget as TheiaPreferencesEditorWidget } from '@theia/preferences/lib/browser/views/preference-editor-widget';
327+
import { PreferencesEditorWidget } from './theia/preferences/preference-editor-widget';
328+
import { PreferencesWidget } from '@theia/preferences/lib/browser/views/preference-widget';
329+
import { createPreferencesWidgetContainer } from '@theia/preferences/lib/browser/views/preference-widget-bindings';
326330

327331
const registerArduinoThemes = () => {
328332
const themes: MonacoThemeJson[] = [
@@ -845,6 +849,18 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
845849
bind(DockPanelRenderer).toSelf();
846850
rebind(TheiaDockPanelRenderer).toService(DockPanelRenderer);
847851

852+
// Avoid running the "reset scroll" interval tasks until the preference editor opens.
853+
rebind(PreferencesWidget)
854+
.toDynamicValue(({ container }) => {
855+
const child = createPreferencesWidgetContainer(container);
856+
child.bind(PreferencesEditorWidget).toSelf().inSingletonScope();
857+
child
858+
.rebind(TheiaPreferencesEditorWidget)
859+
.toService(PreferencesEditorWidget);
860+
return child.get(PreferencesWidget);
861+
})
862+
.inSingletonScope();
863+
848864
// Preferences
849865
bindArduinoPreferences(bind);
850866

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { injectable } from '@theia/core/shared/inversify';
2+
import { PreferencesEditorWidget as TheiaPreferencesEditorWidget } from '@theia/preferences/lib/browser/views/preference-editor-widget';
3+
4+
@injectable()
5+
export class PreferencesEditorWidget extends TheiaPreferencesEditorWidget {
6+
protected override resetScroll(
7+
nodeIDToScrollTo?: string,
8+
filterWasCleared = false
9+
): void {
10+
if (this.scrollBar) {
11+
// Absent on widget creation
12+
this.doResetScroll(nodeIDToScrollTo, filterWasCleared);
13+
} else {
14+
// NOOP
15+
// Unlike Theia, IDE2 does not start multiple tasks to check if the scrollbar is ready to reset it.
16+
// If the "scroll reset" request arrived before the existence of the scrollbar, what to reset?
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)