mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-20 15:19:54 +01:00
333d9a4053
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
13 lines
394 B
TypeScript
13 lines
394 B
TypeScript
import * as path from 'path';
|
|
import * as vscode from 'vscode';
|
|
|
|
export function getRelativeFilePath(uri: vscode.Uri): string | undefined {
|
|
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
|
|
if (!workspaceFolder) {
|
|
return undefined;
|
|
}
|
|
|
|
const workspaceRoot = workspaceFolder.uri.fsPath;
|
|
const absolutePath = uri.fsPath;
|
|
return path.relative(workspaceRoot, absolutePath);
|
|
} |