mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 01:00:29 -04:00
Merge from vscode 31e03b8ffbb218a87e3941f2b63a249f061fe0e4 (#4986)
This commit is contained in:
@@ -32,7 +32,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
|
||||
|
||||
static readonly ID = 'workbench.picker.anything';
|
||||
|
||||
private static readonly LINE_COLON_PATTERN = /[#:\(](\d*)([#:,](\d*))?\)?$/;
|
||||
private static readonly LINE_COLON_PATTERN = /[#:\(](\d*)([#:,](\d*))?\)?\s*$/;
|
||||
|
||||
private static readonly TYPING_SEARCH_DELAY = 200; // This delay accommodates for the user typing a word and then stops typing to start searching
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import { ExplorerFolderContext, ExplorerRootContext, FilesExplorerFocusCondition
|
||||
import { OpenAnythingHandler } from 'vs/workbench/contrib/search/browser/openAnythingHandler';
|
||||
import { OpenSymbolHandler } from 'vs/workbench/contrib/search/browser/openSymbolHandler';
|
||||
import { registerContributions as replaceContributions } from 'vs/workbench/contrib/search/browser/replaceContributions';
|
||||
import { clearHistoryCommand, ClearSearchResultsAction, CloseReplaceAction, CollapseDeepestExpandedLevelAction, copyAllCommand, copyMatchCommand, copyPathCommand, FindInFilesAction, FocusNextInputAction, FocusNextSearchResultAction, FocusPreviousInputAction, FocusPreviousSearchResultAction, focusSearchListCommand, getSearchView, openSearchView, OpenSearchViewletAction, RefreshAction, RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction, ReplaceInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, toggleWholeWordCommand } from 'vs/workbench/contrib/search/browser/searchActions';
|
||||
import { clearHistoryCommand, ClearSearchResultsAction, CloseReplaceAction, CollapseDeepestExpandedLevelAction, copyAllCommand, copyMatchCommand, copyPathCommand, FocusNextInputAction, FocusNextSearchResultAction, FocusPreviousInputAction, FocusPreviousSearchResultAction, focusSearchListCommand, getSearchView, openSearchView, OpenSearchViewletAction, RefreshAction, RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction, ReplaceInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, toggleWholeWordCommand, FindInFilesCommand } from 'vs/workbench/contrib/search/browser/searchActions';
|
||||
import { SearchPanel } from 'vs/workbench/contrib/search/browser/searchPanel';
|
||||
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
|
||||
import { SearchViewlet } from 'vs/workbench/contrib/search/browser/searchViewlet';
|
||||
@@ -523,7 +523,14 @@ const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.Workbenc
|
||||
// Show Search and Find in Files are redundant, but we can't break keybindings by removing one. So it's the same action, same keybinding, registered to different IDs.
|
||||
// Show Search 'when' is redundant but if the two conflict with exactly the same keybinding and 'when' clause, then they can show up as "unbound" - #51780
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenSearchViewletAction, VIEWLET_ID, OpenSearchViewletAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }, Constants.SearchViewVisibleKey.toNegated()), 'View: Show Search', nls.localize('view', "View"));
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(FindInFilesAction, Constants.FindInFilesActionId, nls.localize('findInFiles', "Find in Files"), { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F }), 'Find in Files', category);
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: Constants.FindInFilesActionId,
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: null,
|
||||
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_F,
|
||||
handler: FindInFilesCommand
|
||||
});
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: Constants.FindInFilesActionId, title: { value: nls.localize('findInFiles', "Find in Files"), original: 'Find in Files' }, category } });
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
|
||||
group: '4_find_global',
|
||||
command: {
|
||||
|
||||
@@ -160,19 +160,35 @@ export abstract class FindOrReplaceInFilesAction extends Action {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class FindInFilesAction extends FindOrReplaceInFilesAction {
|
||||
|
||||
static readonly LABEL = nls.localize('findInFiles', "Find in Files");
|
||||
|
||||
constructor(id: string, label: string,
|
||||
@IViewletService viewletService: IViewletService,
|
||||
@IPanelService panelService: IPanelService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
super(id, label, viewletService, panelService, configurationService, /*expandSearchReplaceWidget=*/false);
|
||||
}
|
||||
export interface IFindInFilesArgs {
|
||||
query?: string;
|
||||
replace?: string;
|
||||
triggerSearch?: boolean;
|
||||
filesToInclude?: string;
|
||||
filesToExclude?: string;
|
||||
isRegex?: boolean;
|
||||
isCaseSensitive?: boolean;
|
||||
matchWholeWord?: boolean;
|
||||
}
|
||||
export const FindInFilesCommand: ICommandHandler = (accessor, args: IFindInFilesArgs = {}) => {
|
||||
|
||||
const viewletService = accessor.get(IViewletService);
|
||||
const panelService = accessor.get(IPanelService);
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
openSearchView(viewletService, panelService, configurationService, false).then(openedView => {
|
||||
if (openedView) {
|
||||
const searchAndReplaceWidget = openedView.searchAndReplaceWidget;
|
||||
searchAndReplaceWidget.toggleReplace(typeof args.replace === 'string');
|
||||
let updatedText = false;
|
||||
if (typeof args.query === 'string') {
|
||||
openedView.setSearchParameters(args);
|
||||
} else {
|
||||
updatedText = openedView.updateTextFromSelection((typeof args.replace !== 'string'));
|
||||
}
|
||||
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export class OpenSearchViewletAction extends FindOrReplaceInFilesAction {
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import { OpenFileFolderAction, OpenFolderAction } from 'vs/workbench/browser/act
|
||||
import { ResourceLabels } from 'vs/workbench/browser/labels';
|
||||
import { IEditor } from 'vs/workbench/common/editor';
|
||||
import { ExcludePatternInputWidget, PatternInputWidget } from 'vs/workbench/contrib/search/browser/patternInputWidget';
|
||||
import { CancelSearchAction, ClearSearchResultsAction, CollapseDeepestExpandedLevelAction, RefreshAction } from 'vs/workbench/contrib/search/browser/searchActions';
|
||||
import { CancelSearchAction, ClearSearchResultsAction, CollapseDeepestExpandedLevelAction, RefreshAction, IFindInFilesArgs } 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';
|
||||
@@ -452,8 +452,12 @@ export class SearchView extends ViewletPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
const root = element instanceof SearchResult ? null : element;
|
||||
this.tree.setChildren(root, this.createIterator(element, collapseResults));
|
||||
if (element instanceof SearchResult) {
|
||||
this.tree.setChildren(null, this.createIterator(element, collapseResults));
|
||||
} else {
|
||||
this.tree.setChildren(element, this.createIterator(element, collapseResults));
|
||||
this.tree.rerender(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -642,7 +646,7 @@ export class SearchView extends ViewletPanel {
|
||||
}));
|
||||
this._register(this.tree.onContextMenu(e => this.onContextMenu(e)));
|
||||
|
||||
const resourceNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true }));
|
||||
const resourceNavigator = this._register(new TreeResourceNavigator2(this.tree, { openOnFocus: true, openOnSelection: false }));
|
||||
this._register(Event.debounce(resourceNavigator.onDidOpenResource, (last, event) => event, 75, true)(options => {
|
||||
if (options.element instanceof Match) {
|
||||
const selectedMatch: Match = options.element;
|
||||
@@ -1043,6 +1047,37 @@ export class SearchView extends ViewletPanel {
|
||||
this.onQueryChanged(true);
|
||||
}
|
||||
|
||||
setSearchParameters(args: IFindInFilesArgs = {}): void {
|
||||
if (typeof args.isCaseSensitive === 'boolean') {
|
||||
this.searchWidget.searchInput.setCaseSensitive(args.isCaseSensitive);
|
||||
}
|
||||
if (typeof args.matchWholeWord === 'boolean') {
|
||||
this.searchWidget.searchInput.setWholeWords(args.matchWholeWord);
|
||||
}
|
||||
if (typeof args.isRegex === 'boolean') {
|
||||
this.searchWidget.searchInput.setRegex(args.isRegex);
|
||||
}
|
||||
if (typeof args.filesToInclude === 'string') {
|
||||
this.searchIncludePattern.setValue(String(args.filesToInclude));
|
||||
}
|
||||
if (typeof args.filesToExclude === 'string') {
|
||||
this.searchExcludePattern.setValue(String(args.filesToExclude));
|
||||
}
|
||||
if (typeof args.query === 'string') {
|
||||
this.searchWidget.searchInput.setValue(args.query);
|
||||
}
|
||||
if (typeof args.replace === 'string') {
|
||||
this.searchWidget.replaceInput.value = args.replace;
|
||||
} else {
|
||||
if (this.searchWidget.replaceInput.value !== '') {
|
||||
this.searchWidget.replaceInput.value = '';
|
||||
}
|
||||
}
|
||||
if (typeof args.triggerSearch === 'boolean' && args.triggerSearch) {
|
||||
this.onQueryChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
toggleQueryDetails(moveFocus = true, show?: boolean, skipLayout?: boolean, reverse?: boolean): void {
|
||||
const cls = 'more';
|
||||
show = typeof show === 'undefined' ? !dom.hasClass(this.queryDetails, cls) : Boolean(show);
|
||||
|
||||
Reference in New Issue
Block a user