mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	chore(trace-viewer): copy only file name without line number (#31939)
As discussed in the meeting, copy only file name which is shown in the same line, do not include highlighted line number.
This commit is contained in:
		
							parent
							
								
									e62a54af7a
								
							
						
					
					
						commit
						ecd384212d
					
				| @ -103,7 +103,7 @@ export const SourceTab: React.FunctionComponent<{ | ||||
|     main={<div className='vbox' data-testid='source-code'> | ||||
|       { fileName && <Toolbar> | ||||
|         <span className='source-tab-file-name'>{fileName}</span> | ||||
|         <CopyToClipboard description='Copy filename' value={getFileName(fileName, targetLine)}/> | ||||
|         <CopyToClipboard description='Copy filename' value={getFileName(fileName)}/> | ||||
|         {location && <ToolbarButton icon='link-external' title='Open in VS Code' onClick={openExternally}></ToolbarButton>} | ||||
|       </Toolbar> } | ||||
|       <CodeMirrorWrapper text={source.content || ''} language='javascript' highlight={highlight} revealLine={targetLine} readOnly={true} lineNumbers={true} /> | ||||
| @ -124,10 +124,9 @@ export async function calculateSha1(text: string): Promise<string> { | ||||
|   return hexCodes.join(''); | ||||
| } | ||||
| 
 | ||||
| function getFileName(fullPath?: string, lineNum?: number): string { | ||||
| function getFileName(fullPath?: string): string { | ||||
|   if (!fullPath) | ||||
|     return ''; | ||||
|   const pathSep = fullPath?.includes('/') ? '/' : '\\'; | ||||
|   const fileName = fullPath?.split(pathSep).pop() ?? ''; | ||||
|   return lineNum ? `${fileName}:${lineNum}` : fileName; | ||||
|   return fullPath?.split(pathSep).pop() ?? ''; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Yury Semikhatsky
						Yury Semikhatsky