-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow opening changes for files associated with custom editors (#13916)
* Fix loading of webview resources that depend on query params Some resource url (notably git) use the query part of the url to store additional information. The query part of the url was incorrectly being dropped while attempting to load these resources inside of webviews. See also microsoft/vscode@48387df * Fix `Error: Unknown Webview` messages in the log * Fix design and implementation issues surrounding `CustomEditorOpener` This commit ensures that the promise returned by `CustomEditorOpener.open` will only resolve to a properly initialized and opened `CustomEditorWidget`. In particular, it ensures that the widget is opened according to the specified `WidgetOpenerOptions`, including `widgetOptions.ref` and `mode`. Essentially, it revises the work done in #9671 and #10580 to fix #9670 and #10583. * Restore custom editors as part of layout Fixes an incorrect assumption that a custom editor cannot be restored if no `WebviewPanelSerializer` is registered for its view type. (Actually, custom editors are created and restored using a custom editor provider.) Also, ensures that `CustomEditorWidget.modelRef` satisfies the shape for the `CustomEditorWidget` defined in `editor.ts` and cannot return `undefined`. (However, `CustomEditorWidget.modelRef.object` can be `undefined` until the custom editor is resolved.) Fixes #10787 * Fix a race condition when file system provider is activated When file system provider is activated, wait until it is registered. * git: add support for custom editors * Uses `OpenerService` instead of `EditorManager` to open editors * Contributes a `FileSystemProvider` for git-resources * Fixes an issue with getting blob contents * custom editor: open a diff-uri in a side-by-side editor `CustomEditorOpener` is now able to open a diff-uri in a side-by-side editor, which contains the corresponding `CustomEditor`s. Fixes #9079
- Loading branch information
Showing
31 changed files
with
665 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2024 1C-Soft LLC and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
.theia-split-widget > .p-SplitPanel { | ||
height: 100%; | ||
width: 100%; | ||
outline: none; | ||
} | ||
|
||
.theia-split-widget > .p-SplitPanel > .p-SplitPanel-child { | ||
min-width: 50px; | ||
min-height: var(--theia-content-line-height); | ||
} | ||
|
||
.theia-split-widget > .p-SplitPanel > .p-SplitPanel-handle { | ||
box-sizing: border-box; | ||
} | ||
|
||
.theia-split-widget > .p-SplitPanel[data-orientation="horizontal"] > .p-SplitPanel-handle { | ||
border-left: var(--theia-border-width) solid var(--theia-sideBarSectionHeader-border); | ||
} | ||
|
||
.theia-split-widget > .p-SplitPanel[data-orientation="vertical"] > .p-SplitPanel-handle { | ||
border-top: var(--theia-border-width) solid var(--theia-sideBarSectionHeader-border); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 1C-Soft LLC and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { Emitter } from 'vscode-languageserver-protocol'; | ||
import { ApplicationShell, StatefulWidget } from '../shell'; | ||
import { BaseWidget, Message, PanelLayout, SplitPanel, Widget } from './widget'; | ||
import { CompositeSaveable, Saveable, SaveableSource } from '../saveable'; | ||
import { Navigatable } from '../navigatable-types'; | ||
import { URI } from '../../common'; | ||
|
||
/** | ||
* A widget containing a number of panes in a split layout. | ||
*/ | ||
export class SplitWidget extends BaseWidget implements ApplicationShell.TrackableWidgetProvider, SaveableSource, Navigatable, StatefulWidget { | ||
|
||
protected readonly splitPanel: SplitPanel; | ||
|
||
protected readonly onDidChangeTrackableWidgetsEmitter = new Emitter<Widget[]>(); | ||
readonly onDidChangeTrackableWidgets = this.onDidChangeTrackableWidgetsEmitter.event; | ||
|
||
protected readonly compositeSaveable = new CompositeSaveable(); | ||
|
||
protected navigatable?: Navigatable; | ||
|
||
constructor(options?: SplitPanel.IOptions & { navigatable?: Navigatable }) { | ||
super(); | ||
|
||
this.toDispose.pushAll([this.onDidChangeTrackableWidgetsEmitter]); | ||
|
||
this.addClass('theia-split-widget'); | ||
|
||
const layout = new PanelLayout(); | ||
this.layout = layout; | ||
const that = this; | ||
this.splitPanel = new class extends SplitPanel { | ||
|
||
protected override onChildAdded(msg: Widget.ChildMessage): void { | ||
super.onChildAdded(msg); | ||
that.onPaneAdded(msg.child); | ||
} | ||
|
||
protected override onChildRemoved(msg: Widget.ChildMessage): void { | ||
super.onChildRemoved(msg); | ||
that.onPaneRemoved(msg.child); | ||
} | ||
}({ | ||
spacing: 1, // --theia-border-width | ||
...options | ||
}); | ||
this.splitPanel.node.tabIndex = -1; | ||
layout.addWidget(this.splitPanel); | ||
|
||
this.navigatable = options?.navigatable; | ||
} | ||
|
||
get orientation(): SplitPanel.Orientation { | ||
return this.splitPanel.orientation; | ||
} | ||
|
||
set orientation(value: SplitPanel.Orientation) { | ||
this.splitPanel.orientation = value; | ||
} | ||
|
||
relativeSizes(): number[] { | ||
return this.splitPanel.relativeSizes(); | ||
} | ||
|
||
setRelativeSizes(sizes: number[]): void { | ||
this.splitPanel.setRelativeSizes(sizes); | ||
} | ||
|
||
get handles(): readonly HTMLDivElement[] { | ||
return this.splitPanel.handles; | ||
} | ||
|
||
get saveable(): Saveable { | ||
return this.compositeSaveable; | ||
} | ||
|
||
getResourceUri(): URI | undefined { | ||
return this.navigatable?.getResourceUri(); | ||
} | ||
|
||
createMoveToUri(resourceUri: URI): URI | undefined { | ||
return this.navigatable?.createMoveToUri(resourceUri); | ||
} | ||
|
||
storeState(): SplitWidget.State { | ||
return { orientation: this.orientation, widgets: this.panes, relativeSizes: this.relativeSizes() }; | ||
} | ||
|
||
restoreState(oldState: SplitWidget.State): void { | ||
const { orientation, widgets, relativeSizes } = oldState; | ||
if (orientation) { | ||
this.orientation = orientation; | ||
} | ||
for (const widget of widgets) { | ||
this.addPane(widget); | ||
} | ||
if (relativeSizes) { | ||
this.setRelativeSizes(relativeSizes); | ||
} | ||
} | ||
|
||
get panes(): readonly Widget[] { | ||
return this.splitPanel.widgets; | ||
} | ||
|
||
getTrackableWidgets(): Widget[] { | ||
return [...this.panes]; | ||
} | ||
|
||
protected fireDidChangeTrackableWidgets(): void { | ||
this.onDidChangeTrackableWidgetsEmitter.fire(this.getTrackableWidgets()); | ||
} | ||
|
||
addPane(pane: Widget): void { | ||
this.splitPanel.addWidget(pane); | ||
} | ||
|
||
insertPane(index: number, pane: Widget): void { | ||
this.splitPanel.insertWidget(index, pane); | ||
} | ||
|
||
protected onPaneAdded(pane: Widget): void { | ||
if (Saveable.isSource(pane)) { | ||
this.compositeSaveable.add(pane.saveable); | ||
} | ||
this.fireDidChangeTrackableWidgets(); | ||
} | ||
|
||
protected onPaneRemoved(pane: Widget): void { | ||
if (Saveable.isSource(pane)) { | ||
this.compositeSaveable.remove(pane.saveable); | ||
} | ||
this.fireDidChangeTrackableWidgets(); | ||
} | ||
|
||
protected override onActivateRequest(msg: Message): void { | ||
this.splitPanel.node.focus(); | ||
} | ||
} | ||
|
||
export namespace SplitWidget { | ||
export interface State { | ||
orientation?: SplitPanel.Orientation; | ||
widgets: readonly Widget[]; // note: don't rename this property; it has special meaning for `ShellLayoutRestorer` | ||
relativeSizes?: number[]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 1C-Soft LLC and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { interfaces } from '@theia/core/shared/inversify'; | ||
import { FileService, FileServiceContribution } from '@theia/filesystem/lib/browser/file-service'; | ||
import { GitFileSystemProvider } from './git-file-system-provider'; | ||
import { GIT_RESOURCE_SCHEME } from './git-resource'; | ||
|
||
export class GitFileServiceContribution implements FileServiceContribution { | ||
|
||
constructor(protected readonly container: interfaces.Container) { } | ||
|
||
registerFileSystemProviders(service: FileService): void { | ||
service.onWillActivateFileSystemProvider(event => { | ||
if (event.scheme === GIT_RESOURCE_SCHEME) { | ||
service.registerProvider(GIT_RESOURCE_SCHEME, this.container.get(GitFileSystemProvider)); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.