本文整理汇总了TypeScript中vscode.window.onDidChangeVisibleTextEditors方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.onDidChangeVisibleTextEditors方法的具体用法?TypeScript window.onDidChangeVisibleTextEditors怎么用?TypeScript window.onDidChangeVisibleTextEditors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.onDidChangeVisibleTextEditors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('editor, onDidChangeVisibleTextEditors', () => {
let eventCounter = 0;
let reg = window.onDidChangeVisibleTextEditors(editor => {
eventCounter += 1;
});
return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
return window.showTextDocument(doc, ViewColumn.One).then(editor => {
assert.equal(eventCounter, 1);
return doc;
});
}).then(doc => {
return window.showTextDocument(doc, ViewColumn.Two).then(editor => {
assert.equal(eventCounter, 2);
return doc;
});
}).then(doc => {
return window.showTextDocument(doc, ViewColumn.Three).then(editor => {
assert.equal(eventCounter, 3);
return doc;
});
}).then(doc => {
reg.dispose();
});
});
示例2: realActivation
function realActivation(): void {
if (new CppSettings().intelliSenseEngine === "Disabled") {
throw new Error(intelliSenseDisabledError);
} else {
console.log("activating extension");
let checkForConflictingExtensions: PersistentState<boolean> = new PersistentState<boolean>("CPP." + util.packageJson.version + ".checkForConflictingExtensions", true);
if (checkForConflictingExtensions.Value) {
checkForConflictingExtensions.Value = false;
let clangCommandAdapterActive: boolean = vscode.extensions.all.some((extension: vscode.Extension<any>, index: number, array: vscode.Extension<any>[]): boolean => {
return extension.isActive && extension.id === "mitaki28.vscode-clang";
});
if (clangCommandAdapterActive) {
telemetry.logLanguageServerEvent("conflictingExtension");
}
}
}
realActivationOccurred = true;
console.log("starting language server");
clients = new ClientCollection();
ui = getUI();
// Check for files left open from the previous session. We won't get events for these until they gain focus,
// so we manually activate the visible file.
if (vscode.workspace.textDocuments !== undefined && vscode.workspace.textDocuments.length > 0) {
onDidChangeActiveTextEditor(vscode.window.activeTextEditor);
}
// There may have already been registered CustomConfigurationProviders.
// Request for configurations from those providers.
clients.forEach(client => {
getCustomConfigProviders().forEach(provider => client.onRegisterCustomConfigurationProvider(provider));
});
disposables.push(vscode.workspace.onDidChangeConfiguration(onDidChangeSettings));
disposables.push(vscode.workspace.onDidSaveTextDocument(onDidSaveTextDocument));
disposables.push(vscode.window.onDidChangeActiveTextEditor(onDidChangeActiveTextEditor));
disposables.push(vscode.window.onDidChangeTextEditorSelection(onDidChangeTextEditorSelection));
disposables.push(vscode.window.onDidChangeVisibleTextEditors(onDidChangeVisibleTextEditors));
updateLanguageConfigurations();
reportMacCrashes();
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
if (settings.updateChannel === 'Default') {
suggestInsidersChannel();
} else if (settings.updateChannel === 'Insiders') {
insiderUpdateTimer = setInterval(checkAndApplyUpdate, insiderUpdateTimerInterval, settings.updateChannel);
checkAndApplyUpdate(settings.updateChannel);
}
intervalTimer = setInterval(onInterval, 2500);
}
示例3: Promise
let waitForTextEditorsToClose = new Promise((c, e) => {
if (vscode.window.visibleTextEditors.length === numExpectedEditors) {
return c();
}
vscode.window.onDidChangeVisibleTextEditors(() => {
if (vscode.window.visibleTextEditors.length === numExpectedEditors) {
c();
}
});
});
示例4: Promise
return new Promise((resolve, reject) => {
if (vscode.window.visibleTextEditors.length === 0) {
return resolve();
}
const reg = vscode.window.onDidChangeVisibleTextEditors(editors => {
if (editors.length === 0) {
resolve();
reg.dispose();
}
});
vscode.commands.executeCommand('workbench.action.closeAllEditors').then(undefined, reject);
}).then(() => {
示例5: test
test('editor, onDidChangeVisibleTextEditors', async () => {
let eventCounter = 0;
let reg = window.onDidChangeVisibleTextEditors(_editor => {
eventCounter += 1;
});
const doc = await workspace.openTextDocument(join(workspace.rootPath || '', './far.js'));
await window.showTextDocument(doc, ViewColumn.One);
assert.equal(eventCounter, 1);
await window.showTextDocument(doc, ViewColumn.Two);
assert.equal(eventCounter, 2);
await window.showTextDocument(doc, ViewColumn.Three);
assert.equal(eventCounter, 3);
reg.dispose();
});