diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index 8d421e4391b3881fcfbc7f054497ac9580c3ec17..29af3475e47680df6e0f32794849f134fdc445b5 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -26,6 +26,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { ICommandHandler } from 'vs/platform/commands/common/commands'; import { Schemas } from 'vs/base/common/network'; import { getPathLabel } from 'vs/base/common/labels'; +import URI from 'vs/base/common/uri'; export function isSearchViewFocused(viewletService: IViewletService, panelService: IPanelService): boolean { let searchView = getSearchView(viewletService, panelService); @@ -635,15 +636,14 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction { } } -function fileMatchUriToString(fileMatch: FileMatch): string { - const resource = fileMatch.resource(); +function uriToClipboardString(resource: URI): string { return resource.scheme === Schemas.file ? getPathLabel(resource) : resource.toString(); } -export const copyPathCommand: ICommandHandler = (accessor, fileMatch: FileMatch) => { +export const copyPathCommand: ICommandHandler = (accessor, fileMatch: FileMatch | FolderMatch) => { const clipboardService = accessor.get(IClipboardService); - const text = fileMatchUriToString(fileMatch); + const text = uriToClipboardString(fileMatch.resource()); clipboardService.writeText(text); }; @@ -659,7 +659,7 @@ function fileMatchToString(fileMatch: FileMatch, maxMatches: number): { text: st .map(matchText => ' ' + matchText); return { - text: `${fileMatchUriToString(fileMatch)}${lineDelimiter}${matchTextRows.join(lineDelimiter)}`, + text: `${uriToClipboardString(fileMatch.resource())}${lineDelimiter}${matchTextRows.join(lineDelimiter)}`, count: matchTextRows.length }; } diff --git a/src/vs/workbench/parts/search/browser/searchView.ts b/src/vs/workbench/parts/search/browser/searchView.ts index 67002a97b8624f182a557331d45eca3305789a32..b216b8bb235e1ff4626f0961272efbc1b76c544c 100644 --- a/src/vs/workbench/parts/search/browser/searchView.ts +++ b/src/vs/workbench/parts/search/browser/searchView.ts @@ -82,6 +82,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { private inputPatternIncludesFocused: IContextKey; private firstMatchFocused: IContextKey; private fileMatchOrMatchFocused: IContextKey; + private fileMatchOrFolderMatchFocus: IContextKey; private fileMatchFocused: IContextKey; private folderMatchFocused: IContextKey; private matchFocused: IContextKey; @@ -137,6 +138,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { this.inputPatternIncludesFocused = Constants.PatternIncludesFocusedKey.bindTo(this.contextKeyService); this.firstMatchFocused = Constants.FirstMatchFocusKey.bindTo(contextKeyService); this.fileMatchOrMatchFocused = Constants.FileMatchOrMatchFocusKey.bindTo(contextKeyService); + this.fileMatchOrFolderMatchFocus = Constants.FileMatchOrFolderMatchFocusKey.bindTo(contextKeyService); this.fileMatchFocused = Constants.FileFocusKey.bindTo(contextKeyService); this.folderMatchFocused = Constants.FolderFocusKey.bindTo(contextKeyService); this.matchFocused = Constants.MatchFocusKey.bindTo(this.contextKeyService); @@ -535,6 +537,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { this.fileMatchFocused.set(focus instanceof FileMatch); this.folderMatchFocused.set(focus instanceof FolderMatch); this.matchFocused.set(focus instanceof Match); + this.fileMatchOrFolderMatchFocus.set(focus instanceof FileMatch || focus instanceof FolderMatch); } })); @@ -545,9 +548,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { this.fileMatchFocused.reset(); this.folderMatchFocused.reset(); this.matchFocused.reset(); + this.fileMatchOrFolderMatchFocus.reset(); })); - - }); } diff --git a/src/vs/workbench/parts/search/common/constants.ts b/src/vs/workbench/parts/search/common/constants.ts index a2e93246ec69166954a64ff6debbd7658365417c..78eb76c2af592097139d7bb77cbc5d8053f73d19 100644 --- a/src/vs/workbench/parts/search/common/constants.ts +++ b/src/vs/workbench/parts/search/common/constants.ts @@ -34,7 +34,8 @@ export const ReplaceActiveKey = new RawContextKey('replaceActive', fals export const HasSearchResults = new RawContextKey('hasSearchResult', false); export const FirstMatchFocusKey = new RawContextKey('firstMatchFocus', false); -export const FileMatchOrMatchFocusKey = new RawContextKey('fileMatchOrMatchFocus', false); +export const FileMatchOrMatchFocusKey = new RawContextKey('fileMatchOrMatchFocus', false); // This is actually, Match or File or Folder +export const FileMatchOrFolderMatchFocusKey = new RawContextKey('fileMatchOrFolderMatchFocus', false); export const FileFocusKey = new RawContextKey('fileMatchFocus', false); export const FolderFocusKey = new RawContextKey('folderMatchFocus', false); export const MatchFocusKey = new RawContextKey('matchFocus', false); diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts index 8443056e9c30cedc0dd1fff3fd2a3aaf2637917b..30341762f4c33390e0766551176878e079211e0c 100644 --- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts @@ -256,7 +256,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { KeybindingsRegistry.registerCommandAndKeybindingRule({ id: Constants.CopyPathCommandId, weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), - when: Constants.FileFocusKey, + when: Constants.FileMatchOrFolderMatchFocusKey, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C, win: { primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_C @@ -269,7 +269,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { id: Constants.CopyPathCommandId, title: nls.localize('copyPathLabel', "Copy Path") }, - when: Constants.FileFocusKey, + when: Constants.FileMatchOrFolderMatchFocusKey, group: 'search_2', order: 4 });