本文整理汇总了TypeScript中vscode.window.showWarningMessage方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.showWarningMessage方法的具体用法?TypeScript window.showWarningMessage怎么用?TypeScript window.showWarningMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.showWarningMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: stageAll
@command('git.stageAll', { repository: true })
async stageAll(repository: Repository): Promise<void> {
const resources = repository.mergeGroup.resourceStates.filter(s => s instanceof Resource) as Resource[];
const mergeConflicts = resources.filter(s => s.resourceGroupType === ResourceGroupType.Merge);
if (mergeConflicts.length > 0) {
const message = mergeConflicts.length > 1
? localize('confirm stage files with merge conflicts', "Are you sure you want to stage {0} files with merge conflicts?", mergeConflicts.length)
: localize('confirm stage file with merge conflicts', "Are you sure you want to stage {0} with merge conflicts?", path.basename(mergeConflicts[0].resourceUri.fsPath));
const yes = localize('yes', "Yes");
const pick = await window.showWarningMessage(message, { modal: true }, yes);
if (pick !== yes) {
return;
}
}
await repository.add([]);
}
示例2: localize
return client.onProjectLanguageServiceStateChanged(body => {
if (body.languageServiceEnabled) {
item.hide();
} else {
item.show();
const configFileName = body.projectName;
if (configFileName) {
item.configFileName = configFileName;
vscode.window.showWarningMessage<LargeProjectMessageItem>(item.getCurrentHint().message,
{
title: localize('large.label', "Configure Excludes"),
index: 0
}).then(selected => {
if (selected && selected.index === 0) {
onConfigureExcludesSelected(client, configFileName);
}
});
}
}
});
示例3: publish
@command('git.publish')
async publish(): Promise<void> {
const remotes = this.model.remotes;
if (remotes.length === 0) {
window.showWarningMessage(localize('no remotes to publish', "Your repository has no remotes configured to publish to."));
return;
}
const branchName = this.model.HEAD && this.model.HEAD.name || '';
const picks = this.model.remotes.map(r => r.name);
const placeHolder = localize('pick remote', "Pick a remote to publish the branch '{0}' to:", branchName);
const choice = await window.showQuickPick(picks, { placeHolder });
if (!choice) {
return;
}
await this.model.pushTo(choice, branchName, true);
}
示例4: execShellCMD
function execShellCMD(cwd:string) {
if (process) {
const msg = 'There is an active running shell command right now. Terminate it before executing another shell command.';
vscode.window.showWarningMessage(msg, 'Terminate')
.then((choice) => {
if (choice === 'Terminate') {
term();
}
});
} else {
var lastCmd = commandHistory.last();
var options = {
placeHolder: 'Type your shell command here.',
value: lastCmd ? lastCmd.cmd : undefined
};
vscode.window.showInputBox(options).then((cmd) => {
exec(cmd, cwd);
});
}
}
示例5: execute
async execute(editor: TextEditor, uri?: Uri, args: OpenWorkingFileCommandArgs = {}) {
args = { ...args };
if (args.line === undefined) {
args.line = editor == null ? 0 : editor.selection.active.line;
}
try {
if (args.uri == null) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
args.uri = await GitUri.fromUri(uri);
if (args.uri instanceof GitUri && args.uri.sha) {
const workingUri = await Container.git.getWorkingUri(args.uri.repoPath!, args.uri);
if (workingUri === undefined) {
return window.showWarningMessage(
'Unable to open working file. File could not be found in the working tree'
);
}
args.uri = new GitUri(workingUri, args.uri.repoPath);
}
}
if (args.line !== undefined && args.line !== 0) {
if (args.showOptions === undefined) {
args.showOptions = {};
}
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
}
const e = await openEditor(args.uri, { ...args.showOptions, rethrow: true });
if (args.annotationType === undefined) return e;
return Container.fileAnnotations.show(e!, args.annotationType, args.line);
}
catch (ex) {
Logger.error(ex, 'OpenWorkingFileCommand');
return Messages.showGenericErrorMessage('Unable to open working file');
}
}
示例6: doesAnyAssetExist
doesAnyAssetExist(generator).then(res => {
if (res) {
const yesItem = { title: 'Yes' };
const cancelItem = { title: 'Cancel', isCloseAffordance: true };
vscode.window.showWarningMessage('Replace existing build and debug assets?', cancelItem, yesItem)
.then(selection => {
if (selection === yesItem) {
deleteAssets(generator).then(_ => resolve(true));
}
else {
// The user clicked cancel
resolve(false);
}
});
}
else {
// The assets don't exist, so we're good to go.
resolve(true);
}
});
示例7: open
let disposable = vscode.commands.registerCommand('extension.viewInBrowser', () => {
var editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showWarningMessage('no active text editor!');
return;
}
const file = editor.document.fileName;
const ext = path.extname(file);
if (/^\.(html|htm|shtml|xhtml)$/.test(ext)) {
if(os.platform() == 'linux'){
open(`file:///${file}`,'x-www-browser');
}else{
open(`file:///${file}`);
}
} else {
vscode.window.showInformationMessage('support html file only!');
}
});
示例8: stage
@command('git.stage')
async stage(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
const resource = this.getSCMResource();
if (!resource) {
return;
}
resourceStates = [resource];
}
const selection = resourceStates.filter(s => s instanceof Resource) as Resource[];
const mergeConflicts = selection.filter(s => s.resourceGroupType === ResourceGroupType.Merge);
if (mergeConflicts.length > 0) {
const message = mergeConflicts.length > 1
? localize('confirm stage files with merge conflicts', "Are you sure you want to stage {0} files with merge conflicts?", mergeConflicts.length)
: localize('confirm stage file with merge conflicts', "Are you sure you want to stage {0} with merge conflicts?", path.basename(mergeConflicts[0].resourceUri.fsPath));
const yes = localize('yes', "Yes");
const pick = await window.showWarningMessage(message, { modal: true }, yes);
if (pick !== yes) {
return;
}
}
const workingTree = selection
.filter(s => s.resourceGroupType === ResourceGroupType.WorkingTree);
const scmResources = [...workingTree, ...mergeConflicts];
if (!scmResources.length) {
return;
}
const resources = scmResources.map(r => r.resourceUri);
await this.runByRepository(resources, async (repository, resources) => repository.add(resources));
}
示例9: getTidySettings
/**
* get options from workspace options or from file .htmltidy
*/
private getTidySettings() {
if (!this.tidySettings) {
let options = this.config.optionsTidy;
if (vscode.workspace.workspaceFolders) {
for (let folder of vscode.workspace.workspaceFolders) {
const optionsFileName = path.join(folder.uri.fsPath, '.htmlTidy');
if (fs.existsSync(optionsFileName)) {
try {
const fileOptions = JSON.parse(fs.readFileSync(optionsFileName, 'utf8'));
options = fileOptions;
} catch (err) {
console.error(err);
vscode.window.showWarningMessage(`Options in file ${optionsFileName} not valid`);
}
break;
}
}
}
this.tidySettings = options;
}
return this.tidySettings;
}
示例10: enable
function enable() {
let folders = Workspace.workspaceFolders;
if (!folders) {
Window.showWarningMessage(`${linterName} can only be enabled if VS Code is opened on a workspace folder.`);
return;
}
let disabledFolders = folders.filter(folder => !Workspace.getConfiguration('standard',folder.uri).get('enable', true));
if (disabledFolders.length === 0) {
if (folders.length === 1) {
Window.showInformationMessage(`${linterName} is already enabled in the workspace.`);
} else {
Window.showInformationMessage(`${linterName} is already enabled on all workspace folders.`);
}
return;
}
pickFolder(disabledFolders, `Select a workspace folder to enable ${linterName} for`).then(folder => {
if (!folder) {
return;
}
Workspace.getConfiguration('standard', folder.uri).update('enable', true);
});
}