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

#8594 - Fix Copy Path on folder nodes

上级 c8a6ce93
...@@ -26,6 +26,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService ...@@ -26,6 +26,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { ICommandHandler } from 'vs/platform/commands/common/commands'; import { ICommandHandler } from 'vs/platform/commands/common/commands';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { getPathLabel } from 'vs/base/common/labels'; import { getPathLabel } from 'vs/base/common/labels';
import URI from 'vs/base/common/uri';
export function isSearchViewFocused(viewletService: IViewletService, panelService: IPanelService): boolean { export function isSearchViewFocused(viewletService: IViewletService, panelService: IPanelService): boolean {
let searchView = getSearchView(viewletService, panelService); let searchView = getSearchView(viewletService, panelService);
...@@ -635,15 +636,14 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction { ...@@ -635,15 +636,14 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
} }
} }
function fileMatchUriToString(fileMatch: FileMatch): string { function uriToClipboardString(resource: URI): string {
const resource = fileMatch.resource();
return resource.scheme === Schemas.file ? getPathLabel(resource) : resource.toString(); 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 clipboardService = accessor.get(IClipboardService);
const text = fileMatchUriToString(fileMatch); const text = uriToClipboardString(fileMatch.resource());
clipboardService.writeText(text); clipboardService.writeText(text);
}; };
...@@ -659,7 +659,7 @@ function fileMatchToString(fileMatch: FileMatch, maxMatches: number): { text: st ...@@ -659,7 +659,7 @@ function fileMatchToString(fileMatch: FileMatch, maxMatches: number): { text: st
.map(matchText => ' ' + matchText); .map(matchText => ' ' + matchText);
return { return {
text: `${fileMatchUriToString(fileMatch)}${lineDelimiter}${matchTextRows.join(lineDelimiter)}`, text: `${uriToClipboardString(fileMatch.resource())}${lineDelimiter}${matchTextRows.join(lineDelimiter)}`,
count: matchTextRows.length count: matchTextRows.length
}; };
} }
......
...@@ -82,6 +82,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -82,6 +82,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private inputPatternIncludesFocused: IContextKey<boolean>; private inputPatternIncludesFocused: IContextKey<boolean>;
private firstMatchFocused: IContextKey<boolean>; private firstMatchFocused: IContextKey<boolean>;
private fileMatchOrMatchFocused: IContextKey<boolean>; private fileMatchOrMatchFocused: IContextKey<boolean>;
private fileMatchOrFolderMatchFocus: IContextKey<boolean>;
private fileMatchFocused: IContextKey<boolean>; private fileMatchFocused: IContextKey<boolean>;
private folderMatchFocused: IContextKey<boolean>; private folderMatchFocused: IContextKey<boolean>;
private matchFocused: IContextKey<boolean>; private matchFocused: IContextKey<boolean>;
...@@ -137,6 +138,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -137,6 +138,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.inputPatternIncludesFocused = Constants.PatternIncludesFocusedKey.bindTo(this.contextKeyService); this.inputPatternIncludesFocused = Constants.PatternIncludesFocusedKey.bindTo(this.contextKeyService);
this.firstMatchFocused = Constants.FirstMatchFocusKey.bindTo(contextKeyService); this.firstMatchFocused = Constants.FirstMatchFocusKey.bindTo(contextKeyService);
this.fileMatchOrMatchFocused = Constants.FileMatchOrMatchFocusKey.bindTo(contextKeyService); this.fileMatchOrMatchFocused = Constants.FileMatchOrMatchFocusKey.bindTo(contextKeyService);
this.fileMatchOrFolderMatchFocus = Constants.FileMatchOrFolderMatchFocusKey.bindTo(contextKeyService);
this.fileMatchFocused = Constants.FileFocusKey.bindTo(contextKeyService); this.fileMatchFocused = Constants.FileFocusKey.bindTo(contextKeyService);
this.folderMatchFocused = Constants.FolderFocusKey.bindTo(contextKeyService); this.folderMatchFocused = Constants.FolderFocusKey.bindTo(contextKeyService);
this.matchFocused = Constants.MatchFocusKey.bindTo(this.contextKeyService); this.matchFocused = Constants.MatchFocusKey.bindTo(this.contextKeyService);
...@@ -535,6 +537,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel { ...@@ -535,6 +537,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.fileMatchFocused.set(focus instanceof FileMatch); this.fileMatchFocused.set(focus instanceof FileMatch);
this.folderMatchFocused.set(focus instanceof FolderMatch); this.folderMatchFocused.set(focus instanceof FolderMatch);
this.matchFocused.set(focus instanceof Match); 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 { ...@@ -545,9 +548,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this.fileMatchFocused.reset(); this.fileMatchFocused.reset();
this.folderMatchFocused.reset(); this.folderMatchFocused.reset();
this.matchFocused.reset(); this.matchFocused.reset();
this.fileMatchOrFolderMatchFocus.reset();
})); }));
}); });
} }
......
...@@ -34,7 +34,8 @@ export const ReplaceActiveKey = new RawContextKey<boolean>('replaceActive', fals ...@@ -34,7 +34,8 @@ export const ReplaceActiveKey = new RawContextKey<boolean>('replaceActive', fals
export const HasSearchResults = new RawContextKey<boolean>('hasSearchResult', false); export const HasSearchResults = new RawContextKey<boolean>('hasSearchResult', false);
export const FirstMatchFocusKey = new RawContextKey<boolean>('firstMatchFocus', false); export const FirstMatchFocusKey = new RawContextKey<boolean>('firstMatchFocus', false);
export const FileMatchOrMatchFocusKey = new RawContextKey<boolean>('fileMatchOrMatchFocus', false); export const FileMatchOrMatchFocusKey = new RawContextKey<boolean>('fileMatchOrMatchFocus', false); // This is actually, Match or File or Folder
export const FileMatchOrFolderMatchFocusKey = new RawContextKey<boolean>('fileMatchOrFolderMatchFocus', false);
export const FileFocusKey = new RawContextKey<boolean>('fileMatchFocus', false); export const FileFocusKey = new RawContextKey<boolean>('fileMatchFocus', false);
export const FolderFocusKey = new RawContextKey<boolean>('folderMatchFocus', false); export const FolderFocusKey = new RawContextKey<boolean>('folderMatchFocus', false);
export const MatchFocusKey = new RawContextKey<boolean>('matchFocus', false); export const MatchFocusKey = new RawContextKey<boolean>('matchFocus', false);
...@@ -256,7 +256,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { ...@@ -256,7 +256,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, {
KeybindingsRegistry.registerCommandAndKeybindingRule({ KeybindingsRegistry.registerCommandAndKeybindingRule({
id: Constants.CopyPathCommandId, id: Constants.CopyPathCommandId,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: Constants.FileFocusKey, when: Constants.FileMatchOrFolderMatchFocusKey,
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C, primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_C,
win: { win: {
primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_C primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_C
...@@ -269,7 +269,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, { ...@@ -269,7 +269,7 @@ MenuRegistry.appendMenuItem(MenuId.SearchContext, {
id: Constants.CopyPathCommandId, id: Constants.CopyPathCommandId,
title: nls.localize('copyPathLabel', "Copy Path") title: nls.localize('copyPathLabel', "Copy Path")
}, },
when: Constants.FileFocusKey, when: Constants.FileMatchOrFolderMatchFocusKey,
group: 'search_2', group: 'search_2',
order: 4 order: 4
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册