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

feat: improve editor focus behavior #1448

Merged
merged 2 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/editor/src/browser/tab.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export const Tabs = ({ group }: ITabsProps) => {
}}
onMouseDown={(e) => {
if (e.nativeEvent.which === 1) {
group.open(resource.uri);
group.open(resource.uri, { focus: true });
}
}}
onDragOver={(e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('FileTree should be work while on single workspace model', () => {
handleItemClick(fileNode, TreeNodeType.TreeNode);
const fileDecoration = decorations.getDecorations(fileNode);
expect(fileDecoration?.classlist).toEqual([styles.mod_selected, styles.mod_focused]);
expect(openFile).toBeCalledWith(fileNode.uri, { disableNavigate: true, preview: true });
expect(openFile).toBeCalledWith(fileNode.uri, { disableNavigate: true, preview: true, focus: true });
});

it('Style decoration should be right while click with ctrl/cmd/shift', async () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/file-tree-next/src/browser/file-tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,11 @@ export class FileTreeService extends Tree implements IFileTreeService {
public openFile(uri: URI) {
// 当打开模式为双击同时预览模式生效时,默认单击为预览文件
const preview = this.preferenceService.get<boolean>('editor.previewMode');
this.commandService.executeCommand(EDITOR_COMMANDS.OPEN_RESOURCE.id, uri, { disableNavigate: true, preview });
this.commandService.executeCommand(EDITOR_COMMANDS.OPEN_RESOURCE.id, uri, {
disableNavigate: true,
preview,
focus: true,
});
}

/**
Expand Down