提交 c1aeb66a 编写于 作者: R Rob Lourens

Fix #68798 - F4 must put focus in the opened file

上级 c5a5b8b0
......@@ -659,7 +659,7 @@ export interface SelectionKeyboardEvent extends KeyboardEvent {
preserveFocus?: boolean;
}
export function getSelectionKeyboardEvent(typeArg: string, preserveFocus?: boolean): SelectionKeyboardEvent {
export function getSelectionKeyboardEvent(typeArg = 'keydown', preserveFocus?: boolean): SelectionKeyboardEvent {
const e = new KeyboardEvent(typeArg);
(<SelectionKeyboardEvent>e).preserveFocus = preserveFocus;
......
......@@ -17,18 +17,17 @@ import * as nls from 'vs/nls';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { ICommandHandler } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { ISearchConfiguration, ISearchHistoryService, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { getSelectionKeyboardEvent, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import * as Constants from 'vs/workbench/contrib/search/common/constants';
import { IReplaceService } from 'vs/workbench/contrib/search/common/replace';
import { FileMatch, FileMatchOrMatch, FolderMatch, Match, RenderableMatch, searchMatchComparer, SearchResult, BaseFolderMatch } from 'vs/workbench/contrib/search/common/searchModel';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { BaseFolderMatch, FileMatch, FileMatchOrMatch, FolderMatch, Match, RenderableMatch, searchMatchComparer, SearchResult } from 'vs/workbench/contrib/search/common/searchModel';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ISearchConfiguration, ISearchHistoryService, VIEW_ID } from 'vs/workbench/services/search/common/search';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
export function isSearchViewFocused(viewletService: IViewletService, panelService: IPanelService): boolean {
......@@ -470,7 +469,7 @@ export class RemoveAction extends AbstractSearchAndReplaceAction {
if (nextFocusElement) {
this.viewer.reveal(nextFocusElement);
this.viewer.setFocus([nextFocusElement], getKeyboardEventForEditorOpen());
this.viewer.setFocus([nextFocusElement], getSelectionKeyboardEvent());
}
this.element.parent().remove(<any>this.element);
......@@ -507,7 +506,7 @@ export class ReplaceAllAction extends AbstractSearchAndReplaceAction {
const nextFocusElement = this.getElementToFocusAfterRemoved(tree, this.fileMatch);
return this.fileMatch.parent().replace(this.fileMatch).then(() => {
if (nextFocusElement) {
tree.setFocus([nextFocusElement], getKeyboardEventForEditorOpen());
tree.setFocus([nextFocusElement], getSelectionKeyboardEvent());
}
tree.domFocus();
......@@ -530,7 +529,7 @@ export class ReplaceAllInFolderAction extends AbstractSearchAndReplaceAction {
const nextFocusElement = this.getElementToFocusAfterRemoved(this.viewer, this.folderMatch);
return this.folderMatch.replaceAll().then(() => {
if (nextFocusElement) {
this.viewer.setFocus([nextFocusElement], getKeyboardEventForEditorOpen());
this.viewer.setFocus([nextFocusElement], getSelectionKeyboardEvent());
}
this.viewer.domFocus();
});
......@@ -555,7 +554,7 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
return this.element.parent().replace(this.element).then(() => {
const elementToFocus = this.getElementToFocusAfterReplace();
if (elementToFocus) {
this.viewer.setFocus([elementToFocus], getKeyboardEventForEditorOpen());
this.viewer.setFocus([elementToFocus], getSelectionKeyboardEvent());
}
return this.getElementToShowReplacePreview(elementToFocus);
......@@ -748,13 +747,3 @@ export const focusSearchListCommand: ICommandHandler = accessor => {
searchView.moveFocusToResults();
});
};
export function getKeyboardEventForEditorOpen(options: IEditorOptions = {}): KeyboardEvent {
const fakeKeyboardEvent = new KeyboardEvent('keydown');
if (options.preserveFocus) {
// fake double click
(<any>fakeKeyboardEvent).detail = 2;
}
return fakeKeyboardEvent;
}
......@@ -32,7 +32,7 @@ import { IContextMenuService, IContextViewService } from 'vs/platform/contextvie
import { IConfirmation, IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { FileChangesEvent, FileChangeType, IFileService } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { TreeResourceNavigator2, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { TreeResourceNavigator2, WorkbenchObjectTree, getSelectionKeyboardEvent } from 'vs/platform/list/browser/listService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IPatternInfo, ISearchComplete, ISearchConfiguration, ISearchConfigurationProperties, ISearchHistoryService, ISearchHistoryValues, ITextQuery, SearchErrorCode, VIEW_ID } from 'vs/workbench/services/search/common/search';
......@@ -48,7 +48,7 @@ import { IEditor } from 'vs/workbench/common/editor';
import { IPanel } from 'vs/workbench/common/panel';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { ExcludePatternInputWidget, PatternInputWidget } from 'vs/workbench/contrib/search/browser/patternInputWidget';
import { CancelSearchAction, ClearSearchResultsAction, CollapseDeepestExpandedLevelAction, getKeyboardEventForEditorOpen, RefreshAction } from 'vs/workbench/contrib/search/browser/searchActions';
import { CancelSearchAction, ClearSearchResultsAction, CollapseDeepestExpandedLevelAction, RefreshAction } from 'vs/workbench/contrib/search/browser/searchActions';
import { FileMatchRenderer, FolderMatchRenderer, MatchRenderer, SearchAccessibilityProvider, SearchDelegate, SearchDND } from 'vs/workbench/contrib/search/browser/searchResultsView';
import { ISearchWidgetOptions, SearchWidget } from 'vs/workbench/contrib/search/browser/searchWidget';
import * as Constants from 'vs/workbench/contrib/search/common/constants';
......@@ -699,7 +699,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
selectCurrentMatch(): void {
const focused = this.tree.getFocus()[0];
const fakeKeyboardEvent = getKeyboardEventForEditorOpen({ preserveFocus: false });
const fakeKeyboardEvent = getSelectionKeyboardEvent(undefined, false);
this.tree.setSelection([focused], fakeKeyboardEvent);
}
......@@ -734,8 +734,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
// Reveal the newly selected element
if (next) {
this.tree.setFocus([next]);
this.tree.setSelection([next]);
this.tree.setFocus([next], getSelectionKeyboardEvent(undefined, false));
this.tree.reveal(next);
this.selectCurrentMatchEmitter.fire(undefined);
}
......@@ -775,8 +774,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
// Reveal the newly selected element
if (prev) {
this.tree.setFocus([prev]);
this.tree.setSelection([prev]);
this.tree.setFocus([prev], getSelectionKeyboardEvent(undefined, false));
this.tree.reveal(prev);
this.selectCurrentMatchEmitter.fire(undefined);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册