Skip to content

Commit

Permalink
Fixes for restoration of minimised panels (#3193)
Browse files Browse the repository at this point in the history
* Only restore panel when opening the panel

* Don't call `restorePanel()` from actions

It's called if needed from `openView()`

* Restore minimised and focused panel when opening a view
  • Loading branch information
lionel- authored May 22, 2024
1 parent 0487b72 commit cd93dea
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/paneCompositePart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
}

// --- Start Positron ---
// If the panel is minimized, restore it.
if (this.layoutService.isPanelMinimized()) {
// If we're opening a view in the panel and it is minimized, restore it.
if (this.partId === Parts.PANEL_PART && this.layoutService.isPanelMinimized()) {
this.layoutService.restorePanel();
}
// --- End Positron ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
import { IExecutionHistoryService } from 'vs/workbench/contrib/executionHistory/common/executionHistoryService';
Expand Down Expand Up @@ -143,13 +142,10 @@ export function registerPositronConsoleActions() {
* @param accessor The services accessor.
*/
async run(accessor: ServicesAccessor) {

const layoutService = accessor.get(IWorkbenchLayoutService);
const viewsService = accessor.get(IViewsService);

// Ensure that the panel and console are visible. This is essentially
// equivalent to what `workbench.panel.positronConsole.focus` does.
layoutService.restorePanel();
await viewsService.openView(POSITRON_CONSOLE_VIEW_ID, true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ISettableObservable, observableValue } from 'vs/base/common/observableI
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { RuntimeItem } from 'vs/workbench/services/positronConsole/browser/classes/runtimeItem';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
Expand Down Expand Up @@ -187,7 +186,6 @@ class PositronConsoleService extends Disposable implements IPositronConsoleServi
@IRuntimeSessionService private readonly _runtimeSessionService: IRuntimeSessionService,
@ILogService private readonly _logService: ILogService,
@IViewsService private readonly _viewsService: IViewsService,
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService
) {
// Call the disposable constrcutor.
super();
Expand Down Expand Up @@ -367,9 +365,8 @@ class PositronConsoleService extends Disposable implements IPositronConsoleServi
* @returns A value which indicates whether the code could be executed.
*/
async executeCode(languageId: string, code: string, focus: boolean, allowIncomplete?: boolean) {
// When code is executed in the console service, ensure that the panel is restored, if it
// needs to be, and open the console view.
this._layoutService.restorePanel();
// When code is executed in the console service, open the console view. This opens
// the relevant pane composite if needed.
await this._viewsService.openView(POSITRON_CONSOLE_VIEW_ID, false);

// Get the running runtimes for the language.
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/services/views/browser/viewsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,18 @@ export class ViewsService extends Disposable implements IViewsService {
if (focusedViewId === viewDescriptor.id) {

const viewLocation = viewDescriptorService.getViewLocationById(viewDescriptor.id);
// --- Start Positron ---
// This deals with an edge case. If we're opening a view
// in the panel, and it is minimized, and it is focused
// (unlikely but possible, e.g. after clicking the
// minimize button), restore it.
if (viewLocation === ViewContainerLocation.Panel && layoutService.isPanelMinimized()) {
layoutService.restorePanel();
// Returning early instead of chaining with `else` to avoid formatter
// indenting the other branches
return;
}
// --- End Positron ---
if (viewDescriptorService.getViewLocationById(viewDescriptor.id) === ViewContainerLocation.Sidebar) {
// focus the editor if the view is focused and in the side bar
editorGroupService.activeGroup.focus();
Expand Down

0 comments on commit cd93dea

Please sign in to comment.