Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new untitled file when double clicking on the main area or tabbar #12867

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ export class ApplicationShell extends Widget {
protected readonly onDidChangeCurrentWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
readonly onDidChangeCurrentWidget = this.onDidChangeCurrentWidgetEmitter.event;

protected readonly onDidRequestNewUntitledTextFileEmitter = new Emitter<void>();
readonly onDidRequestNewUntitledTextFile = this.onDidRequestNewUntitledTextFileEmitter.event;
KR155E marked this conversation as resolved.
Show resolved Hide resolved

@inject(TheiaDockPanel.Factory)
protected readonly dockPanelFactory: TheiaDockPanel.Factory;

Expand Down Expand Up @@ -578,6 +581,14 @@ export class ApplicationShell extends Widget {
}
}
});

dockPanel.node.addEventListener('dblclick', event => {
const el = event.target as Element;
if (el.id === MAIN_AREA_ID || el.classList.contains('p-TabBar-content')) {
this.onDidRequestNewUntitledTextFileEmitter.fire();
}
});

const handler = (e: DragEvent) => {
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'link';
Expand Down
9 changes: 6 additions & 3 deletions packages/editor/src/browser/editor-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import { injectable, postConstruct, inject } from '@theia/core/shared/inversify';
import URI from '@theia/core/lib/common/uri';
import { RecursivePartial, Emitter, Event, MaybePromise } from '@theia/core/lib/common';
import { WidgetOpenerOptions, NavigatableWidgetOpenHandler, NavigatableWidgetOptions, Widget, PreferenceService } from '@theia/core/lib/browser';
import { RecursivePartial, Emitter, Event, MaybePromise, CommandService } from '@theia/core/lib/common';
import { WidgetOpenerOptions, NavigatableWidgetOpenHandler, NavigatableWidgetOptions, Widget, PreferenceService, CommonCommands } from '@theia/core/lib/browser';
import { EditorWidget } from './editor-widget';
import { Range, Position, Location, TextEditor } from './editor';
import { EditorWidgetFactory } from './editor-widget-factory';
Expand Down Expand Up @@ -54,13 +54,16 @@ export class EditorManager extends NavigatableWidgetOpenHandler<EditorWidget> {
*/
readonly onCurrentEditorChanged: Event<EditorWidget | undefined> = this.onCurrentEditorChangedEmitter.event;

@inject(CommandService) protected readonly commands: CommandService;
@inject(PreferenceService) protected readonly preferenceService: PreferenceService;

@postConstruct()
protected override init(): void {
super.init();
this.shell.onDidChangeActiveWidget(() => this.updateActiveEditor());
this.shell.onDidChangeCurrentWidget(() => this.updateCurrentEditor());
KR155E marked this conversation as resolved.
Show resolved Hide resolved
this.shell.onDidRequestNewUntitledTextFile(() =>
this.commands.executeCommand(CommonCommands.NEW_UNTITLED_TEXT_FILE.id)
);
this.onCreated(widget => {
widget.onDidChangeVisibility(() => {
if (widget.isVisible) {
Expand Down
Loading