Ask user to commit/push changes when copying links (#185802)

* Ask user to commit/push changes when copying links

* Don't show an error message for cancellation errors
This commit is contained in:
Joyce Er
2023-06-21 15:28:32 -07:00
committed by GitHub
parent 838ff6266a
commit 31478cefc5
3 changed files with 68 additions and 8 deletions

View File

@@ -11,21 +11,25 @@ import { LinkContext, getLink, getVscodeDevHost } from './links';
async function copyVscodeDevLink(gitAPI: GitAPI, useSelection: boolean, context: LinkContext, includeRange = true) {
try {
const permalink = getLink(gitAPI, useSelection, getVscodeDevHost(), 'headlink', context, includeRange);
const permalink = await getLink(gitAPI, useSelection, getVscodeDevHost(), 'headlink', context, includeRange);
if (permalink) {
return vscode.env.clipboard.writeText(permalink);
}
} catch (err) {
vscode.window.showErrorMessage(err.message);
if (!(err instanceof vscode.CancellationError)) {
vscode.window.showErrorMessage(err.message);
}
}
}
async function openVscodeDevLink(gitAPI: GitAPI): Promise<vscode.Uri | undefined> {
try {
const headlink = getLink(gitAPI, true, getVscodeDevHost(), 'headlink');
const headlink = await getLink(gitAPI, true, getVscodeDevHost(), 'headlink');
return headlink ? vscode.Uri.parse(headlink) : undefined;
} catch (err) {
vscode.window.showErrorMessage(err.message);
if (!(err instanceof vscode.CancellationError)) {
vscode.window.showErrorMessage(err.message);
}
return undefined;
}
}