当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CancellationTokenSource.cancel方法代码示例

本文整理汇总了TypeScript中vscode.CancellationTokenSource.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CancellationTokenSource.cancel方法的具体用法?TypeScript CancellationTokenSource.cancel怎么用?TypeScript CancellationTokenSource.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode.CancellationTokenSource的用法示例。


在下文中一共展示了CancellationTokenSource.cancel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('showInputBox - cancel early', async function () {
		const source = new CancellationTokenSource();
		source.cancel();
		const p = window.showInputBox(undefined, source.token);
		const value = await p;
		assert.equal(value, undefined);
	});
开发者ID:joelday,项目名称:vscode,代码行数:7,代码来源:window.test.ts

示例2:

 items = items.then(itms => {
     if (itms.length <= 1) {
         autoPick = itms[0];
         cancellation.cancel();
     }
     return itms;
 });
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:7,代码来源:referencesQuickPick.ts

示例3: test

	test('showQuickPick, cancel early', function () {
		const source = new CancellationTokenSource();
		source.cancel();
		const p = window.showQuickPick(['eins', 'zwei', 'drei'], undefined, source.token);
		return p.then(value => {
			assert.equal(value, undefined);
		});
	});
开发者ID:sandy081,项目名称:vscode,代码行数:8,代码来源:window.test.ts

示例4: test

	test('findFiles, cancellation', () => {

		const source = new CancellationTokenSource();
		const token = source.token; // just to get an instance first
		source.cancel();

		return workspace.findFiles('*.js', null, 100, token).then((res) => {
			assert.equal(res, void 0);
		});
	});
开发者ID:sangohan,项目名称:KodeStudio,代码行数:10,代码来源:workspace.test.ts

示例5: show

    static async show(
        stash: GitStash,
        mode: 'list' | 'apply',
        progressCancellation: CancellationTokenSource,
        goBackCommand?: CommandQuickPickItem,
        currentCommand?: CommandQuickPickItem
    ): Promise<CommitQuickPickItem<GitStashCommit> | CommandQuickPickItem | undefined> {
        const items = ((stash &&
            Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem<GitStashCommit>(c)))) ||
            []) as (CommitQuickPickItem<GitStashCommit> | CommandQuickPickItem)[];

        if (mode === 'list') {
            const commandArgs: StashSaveCommandArgs = {
                goBackCommand: currentCommand
            };
            items.splice(
                0,
                0,
                new CommandQuickPickItem(
                    {
                        label: '$(plus) Stash Changes',
                        description: `${Strings.pad(GlyphChars.Dash, 2, 3)} stashes all changes`
                    },
                    Commands.StashSave,
                    [commandArgs]
                )
            );
        }

        if (goBackCommand) {
            items.splice(0, 0, goBackCommand);
        }

        if (progressCancellation.token.isCancellationRequested) return undefined;

        const scope = await Container.keyboard.beginScope({ left: goBackCommand });

        progressCancellation.cancel();

        const pick = await window.showQuickPick(items, {
            matchOnDescription: true,
            placeHolder:
                mode === 'apply'
                    ? `Apply stashed changes to your working tree${GlyphChars.Ellipsis}`
                    : `stashed changes ${GlyphChars.Dash} search by message, filename, or commit id`,
            ignoreFocusOut: getQuickPickIgnoreFocusOut()
            // onDidSelectItem: (item: QuickPickItem) => {
            //     scope.setKeyCommand('right', item);
            // }
        });

        await scope.dispose();

        return pick;
    }
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:55,代码来源:stashListQuickPick.ts

示例6: cancelCommandExecution

export function cancelCommandExecution() {
  if (cancellationTokenSource) {
    cancellationTokenSource.cancel();
    cancellationTokenSource = undefined;
    resetStatusBarItem();
    if (statusTimer) {
      clearInterval(statusTimer);
      statusTimer = undefined;
    }
  }
}
开发者ID:nertofiveone,项目名称:salesforcedx-vscode,代码行数:11,代码来源:statusBar.ts

示例7: show

    static async show(
        log: GitLog | undefined,
        placeHolder: string,
        progressCancellation: CancellationTokenSource,
        options: {
            goBackCommand?: CommandQuickPickItem;
            showAllCommand?: CommandQuickPickItem;
            showInViewCommand?: CommandQuickPickItem;
        }
    ): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
        const items = ((log && [...Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))]) || [
            new MessageQuickPickItem('No results found')
        ]) as (CommitQuickPickItem | CommandQuickPickItem)[];

        if (options.showInViewCommand !== undefined) {
            items.splice(0, 0, options.showInViewCommand);
        }

        if (options.showAllCommand !== undefined) {
            items.splice(0, 0, options.showAllCommand);
        }

        if (options.goBackCommand !== undefined) {
            items.splice(0, 0, options.goBackCommand);
        }

        if (progressCancellation.token.isCancellationRequested) return undefined;

        const scope = await Container.keyboard.beginScope({ left: options.goBackCommand });

        progressCancellation.cancel();

        const pick = await window.showQuickPick(items, {
            matchOnDescription: true,
            placeHolder: placeHolder,
            ignoreFocusOut: getQuickPickIgnoreFocusOut()
            // onDidSelectItem: (item: QuickPickItem) => {
            //     scope.setKeyCommand('right', item);
            // }
        });

        await scope.dispose();

        return pick;
    }
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:45,代码来源:commitsQuickPick.ts


注:本文中的vscode.CancellationTokenSource.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。