Skip to content

Commit

Permalink
feat: improve editor focus behavior (opensumi#1448)
Browse files Browse the repository at this point in the history
* feat: improve editor focus behavior

* fix: test case
  • Loading branch information
Aaaaash authored Aug 3, 2022
1 parent 68b8387 commit c4224d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
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

0 comments on commit c4224d8

Please sign in to comment.