@@ -7,14 +7,11 @@ import * as DOM from 'vs/base/browser/dom';
77import { Action } from 'vs/base/common/actions' ;
88import { INavigator } from 'vs/base/common/iterator' ;
99import { createKeybinding , ResolvedKeybinding } from 'vs/base/common/keyCodes' ;
10- import { normalizeDriveLetter } from 'vs/base/common/labels' ;
11- import { Schemas } from 'vs/base/common/network' ;
12- import { normalize } from 'vs/base/common/path' ;
1310import { isWindows , OS } from 'vs/base/common/platform' ;
1411import { repeat } from 'vs/base/common/strings' ;
15- import { URI } from 'vs/base/common/uri' ;
1612import * as nls from 'vs/nls' ;
1713import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
14+ import { ILabelService } from 'vs/platform/label/common/label' ;
1815import { ICommandHandler } from 'vs/platform/commands/common/commands' ;
1916import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2017import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
@@ -667,14 +664,11 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
667664 }
668665}
669666
670- function uriToClipboardString ( resource : URI ) : string {
671- return resource . scheme === Schemas . file ? normalize ( normalizeDriveLetter ( resource . fsPath ) ) : resource . toString ( ) ;
672- }
673-
674667export const copyPathCommand : ICommandHandler = async ( accessor , fileMatch : FileMatch | FolderMatch ) => {
675668 const clipboardService = accessor . get ( IClipboardService ) ;
669+ const labelService = accessor . get ( ILabelService ) ;
676670
677- const text = uriToClipboardString ( fileMatch . resource ) ;
671+ const text = labelService . getUriLabel ( fileMatch . resource , { noPrefix : true } ) ;
678672 await clipboardService . writeText ( text ) ;
679673} ;
680674
@@ -706,25 +700,26 @@ function matchToString(match: Match, indent = 0): string {
706700}
707701
708702const lineDelimiter = isWindows ? '\r\n' : '\n' ;
709- function fileMatchToString ( fileMatch : FileMatch , maxMatches : number ) : { text : string , count : number } {
703+ function fileMatchToString ( fileMatch : FileMatch , maxMatches : number , labelService : ILabelService ) : { text : string , count : number } {
710704 const matchTextRows = fileMatch . matches ( )
711705 . sort ( searchMatchComparer )
712706 . slice ( 0 , maxMatches )
713707 . map ( match => matchToString ( match , 2 ) ) ;
708+ const uriString = labelService . getUriLabel ( fileMatch . resource , { noPrefix : true } ) ;
714709 return {
715- text : `${ uriToClipboardString ( fileMatch . resource ) } ${ lineDelimiter } ${ matchTextRows . join ( lineDelimiter ) } ` ,
710+ text : `${ uriString } ${ lineDelimiter } ${ matchTextRows . join ( lineDelimiter ) } ` ,
716711 count : matchTextRows . length
717712 } ;
718713}
719714
720- function folderMatchToString ( folderMatch : FolderMatch | BaseFolderMatch , maxMatches : number ) : { text : string , count : number } {
715+ function folderMatchToString ( folderMatch : FolderMatch | BaseFolderMatch , maxMatches : number , labelService : ILabelService ) : { text : string , count : number } {
721716 const fileResults : string [ ] = [ ] ;
722717 let numMatches = 0 ;
723718
724719 const matches = folderMatch . matches ( ) . sort ( searchMatchComparer ) ;
725720
726721 for ( let i = 0 ; i < folderMatch . fileCount ( ) && numMatches < maxMatches ; i ++ ) {
727- const fileResult = fileMatchToString ( matches [ i ] , maxMatches - numMatches ) ;
722+ const fileResult = fileMatchToString ( matches [ i ] , maxMatches - numMatches , labelService ) ;
728723 numMatches += fileResult . count ;
729724 fileResults . push ( fileResult . text ) ;
730725 }
@@ -738,27 +733,28 @@ function folderMatchToString(folderMatch: FolderMatch | BaseFolderMatch, maxMatc
738733const maxClipboardMatches = 1e4 ;
739734export const copyMatchCommand : ICommandHandler = async ( accessor , match : RenderableMatch ) => {
740735 const clipboardService = accessor . get ( IClipboardService ) ;
736+ const labelService = accessor . get ( ILabelService ) ;
741737
742738 let text : string | undefined ;
743739 if ( match instanceof Match ) {
744740 text = matchToString ( match ) ;
745741 } else if ( match instanceof FileMatch ) {
746- text = fileMatchToString ( match , maxClipboardMatches ) . text ;
742+ text = fileMatchToString ( match , maxClipboardMatches , labelService ) . text ;
747743 } else if ( match instanceof BaseFolderMatch ) {
748- text = folderMatchToString ( match , maxClipboardMatches ) . text ;
744+ text = folderMatchToString ( match , maxClipboardMatches , labelService ) . text ;
749745 }
750746
751747 if ( text ) {
752748 await clipboardService . writeText ( text ) ;
753749 }
754750} ;
755751
756- function allFolderMatchesToString ( folderMatches : Array < FolderMatch | BaseFolderMatch > , maxMatches : number ) : string {
752+ function allFolderMatchesToString ( folderMatches : Array < FolderMatch | BaseFolderMatch > , maxMatches : number , labelService : ILabelService ) : string {
757753 const folderResults : string [ ] = [ ] ;
758754 let numMatches = 0 ;
759755 folderMatches = folderMatches . sort ( searchMatchComparer ) ;
760756 for ( let i = 0 ; i < folderMatches . length && numMatches < maxMatches ; i ++ ) {
761- const folderResult = folderMatchToString ( folderMatches [ i ] , maxMatches - numMatches ) ;
757+ const folderResult = folderMatchToString ( folderMatches [ i ] , maxMatches - numMatches , labelService ) ;
762758 if ( folderResult . count ) {
763759 numMatches += folderResult . count ;
764760 folderResults . push ( folderResult . text ) ;
@@ -772,12 +768,13 @@ export const copyAllCommand: ICommandHandler = async (accessor) => {
772768 const viewletService = accessor . get ( IViewletService ) ;
773769 const panelService = accessor . get ( IPanelService ) ;
774770 const clipboardService = accessor . get ( IClipboardService ) ;
771+ const labelService = accessor . get ( ILabelService ) ;
775772
776773 const searchView = getSearchView ( viewletService , panelService ) ;
777774 if ( searchView ) {
778775 const root = searchView . searchResult ;
779776
780- const text = allFolderMatchesToString ( root . folderMatches ( ) , maxClipboardMatches ) ;
777+ const text = allFolderMatchesToString ( root . folderMatches ( ) , maxClipboardMatches , labelService ) ;
781778 await clipboardService . writeText ( text ) ;
782779 }
783780} ;
0 commit comments