本文整理汇总了TypeScript中vscode.window.onDidChangeActiveTextEditor方法的典型用法代码示例。如果您正苦于以下问题:TypeScript window.onDidChangeActiveTextEditor方法的具体用法?TypeScript window.onDidChangeActiveTextEditor怎么用?TypeScript window.onDidChangeActiveTextEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.window
的用法示例。
在下文中一共展示了window.onDidChangeActiveTextEditor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: activate
export function activate(context: vscode.ExtensionContext) {
let confViewer = new configuration.ConfigurationViewer;
context.subscriptions.push(confViewer);
context.subscriptions.push(vscode.commands.registerCommand('clang.showExecConf', () => {
let editor = vscode.window.activeTextEditor;
if (editor == null) {
vscode.window.showErrorMessage(`No active editor.`);
return;
}
if (!vscode.languages.match(CLANG_MODE, editor.document)) {
vscode.window.showErrorMessage(`Current language is not C, C++ or Objective-C`);
return;
}
confViewer.show(editor.document);
}));
let confTester = new configuration.ConfigurationTester;
context.subscriptions.push(confTester);
let subscriptions: vscode.Disposable[] = [];
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (!vscode.languages.match(CLANG_MODE, editor.document)) return;
confTester.test(editor.document.languageId);
}, null, subscriptions);
let residentExtension: ResidentExtension = new ResidentExtension();
context.subscriptions.push(residentExtension);
vscode.workspace.onDidChangeConfiguration(() => {
residentExtension.update();
}, null, subscriptions);
context.subscriptions.push(vscode.Disposable.from(...subscriptions));
}
示例2: getRange
const command = vscode.commands.registerTextEditorCommand('lebab.convert', (textEditor) => {
const options = vscode.workspace.getConfiguration().get<IOptions>('lebab');
const document = textEditor.document;
const selections = textEditor.selections;
const transforms: ITask[] = [];
const collection = vscode.languages.createDiagnosticCollection();
// If the primary selection is empty, then transform full document
if (isEmptyPrimarySelection(selections)) {
const lastLine = document.lineAt(document.lineCount - 1);
const range = getRange(0, 0, document.lineCount - 1, lastLine.text.length);
transforms.push(transformRange(document, range, options, collection));
} else {
selections.forEach((selection) => {
const range = new vscode.Range(selection.start, selection.end);
transforms.push(transformRange(document, range, options, collection, true));
});
}
if (!options.skipWarnings) {
vscode.window.onDidChangeActiveTextEditor(() => collection.delete(document.uri));
}
textEditor.edit((editBuilder) => {
transforms.forEach((task) => {
editBuilder.replace(task.range, task.code);
});
});
});
示例3: activate
export function activate(context: ExtensionContext): void {
let MODE_ID_TS = 'typescript';
let MODE_ID_TSX = 'typescriptreact';
let MODE_ID_JS = 'javascript';
let MODE_ID_JSX = 'javascriptreact';
let clientHost = new TypeScriptServiceClientHost();
let client = clientHost.serviceClient;
context.subscriptions.push(commands.registerCommand('typescript.reloadProjects', () => {
clientHost.reloadProjects();
}));
window.onDidChangeActiveTextEditor(VersionStatus.showHideStatus, null, context.subscriptions);
// Register the supports for both TS and TSX so that we can have separate grammars but share the mode
client.onReady().then(() => {
registerSupports(MODE_ID_TS, clientHost, client);
registerSupports(MODE_ID_TSX, clientHost, client);
registerSupports(MODE_ID_JS, clientHost, client);
registerSupports(MODE_ID_JSX, clientHost, client);
}, () => {
// Nothing to do here. The client did show a message;
});
}
示例4: activate
export function activate(context: vscode.ExtensionContext) {
const vim = new Vim();
let disposable = vscode.commands.registerCommand("type", args => {
vim.key(args.text);
});
context.subscriptions.push(disposable);
disposable = vscode.commands.registerCommand("extension.vimEscape", () => {
vim.key("<esc>");
});
context.subscriptions.push(disposable);
vscode.window.onDidChangeTextEditorSelection(e => {
vim.updateSelection(e.selections);
});
vscode.workspace.onDidChangeTextDocument(e => {
vim.documentChanged(e);
});
vscode.window.onDidChangeActiveTextEditor(e => {
vim.updateUI();
});
vim.updateUI();
}
示例5: loadConfiguration
function loadConfiguration(context: ExtensionContext): void {
const section = workspace.getConfiguration('npm');
if (section) {
validationEnabled = section.get<boolean>('validate.enable', true);
}
diagnosticCollection.clear();
if (validationEnabled) {
workspace.onDidSaveTextDocument(document => {
validateDocument(document);
}, null, context.subscriptions);
window.onDidChangeActiveTextEditor(editor => {
if (editor && editor.document) {
validateDocument(editor.document);
}
}, null, context.subscriptions);
// remove markers on close
workspace.onDidCloseTextDocument(_document => {
diagnosticCollection.clear();
}, null, context.subscriptions);
// workaround for onDidOpenTextDocument
// workspace.onDidOpenTextDocument(document => {
// console.log("onDidOpenTextDocument ", document.fileName);
// validateDocument(document);
// }, null, context.subscriptions);
validateAllDocuments();
}
}
示例6: setup
export function setup(disposables, flowPath) {
lastDiagnostics = vscode.languages.createDiagnosticCollection();
// Do an initial call to get diagnostics from the active editor if any
if (vscode.window.activeTextEditor) {
console.log('INIT');
fullDiagnostics(flowPath);
}
// Update diagnostics: when active text editor changes
disposables.push(vscode.window.onDidChangeActiveTextEditor(editor => {
console.log('CHANGE');
fileDiagnostics(editor && editor.document, flowPath);
}));
// Update diagnostics when document is edited
disposables.push(vscode.workspace.onDidChangeTextDocument(event => {
console.log('EDIT');
if (vscode.window.activeTextEditor) {
fileDiagnostics(vscode.window.activeTextEditor.document, flowPath);
}
}));
// Update diagnostics when document is saved
disposables.push(vscode.workspace.onDidSaveTextDocument(event => {
console.log('SAVE');
if (vscode.window.activeTextEditor) {
fullDiagnostics(flowPath);
}
}));
}
示例7: activate
export function activate(context: vscode.ExtensionContext) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "ts-extension" is now active!');
const diagnostics = [];
vscode.window.onDidChangeActiveTextEditor(e => {
const collection = vscode.languages.createDiagnosticCollection('isidor');
const diagnostic = new vscode.Diagnostic(new vscode.Range(1, 2, 10, 10), 'hello world',)
diagnostic.relatedInformation = [new vscode.DiagnosticRelatedInformation(new vscode.Location(e.document.uri, new vscode.Range(1, 5, 10, 10)), 'related information'),
new vscode.DiagnosticRelatedInformation(new vscode.Location(e.document.uri, new vscode.Range(1, 5, 10, 10)), 'related information 2'),
new vscode.DiagnosticRelatedInformation(new vscode.Location(e.document.uri, new vscode.Range(1, 5, 10, 10)), 'related information 3')]
collection.set(e.document.uri, [diagnostic ])
})
// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
let disposable = vscode.commands.registerCommand('extension.sayHello', () => {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
vscode.window.showInformationMessage('Hello World!');
});
context.subscriptions.push(disposable);
}
示例8: registerLinters
export function registerLinters(ctx: ExtensionContext) {
const globalConfig = getGlobalLintConfig();
const linters = new LintCollection(globalConfig, vscode.workspace.getConfiguration("ruby").lint, vscode.workspace.rootPath);
ctx.subscriptions.push(linters);
function executeLinting(e: vscode.TextEditor | vscode.TextDocumentChangeEvent) {
if (!e) return;
linters.run(e.document);
}
// Debounce linting to prevent running on every keypress, only run when typing has stopped
const lintDebounceTime = vscode.workspace.getConfiguration('ruby').lintDebounceTime;
const executeDebouncedLinting = debounce(executeLinting, lintDebounceTime);
ctx.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(executeLinting));
ctx.subscriptions.push(vscode.workspace.onDidChangeTextDocument(executeDebouncedLinting));
ctx.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
const docs = vscode.window.visibleTextEditors.map(editor => editor.document);
console.log("Config changed. Should lint:", docs.length);
const globalConfig = getGlobalLintConfig();
linters.cfg(vscode.workspace.getConfiguration("ruby").lint, globalConfig);
docs.forEach(doc => linters.run(doc));
}));
// run against all of the current open files
vscode.window.visibleTextEditors.forEach(executeLinting);
}
示例9: constructor
constructor() {
const subscriptions: Disposable[] = [];
window.onDidChangeActiveTextEditor(Display.updateEditor, this, subscriptions);
var config = workspace.getConfiguration('perforce');
if(config && PerforceCommands.checkFolderOpened()) {
if(config['editOnFileSave']) {
workspace.onWillSaveTextDocument(e => {
e.waitUntil(this.onWillSaveFile(e.document));
}, this, subscriptions);
}
if(config['editOnFileModified']) {
workspace.onDidChangeTextDocument(this.onFileModified, this, subscriptions);
}
if(config['addOnFileCreate'] || config['deleteOnFileDelete']) {
this._watcher = workspace.createFileSystemWatcher('**/*', false, true, false);
if(config['addOnFileCreate']) {
this._watcher.onDidCreate(this.onFileCreated, this, subscriptions);
}
if(config['deleteOnFileDelete']) {
this._watcher.onDidDelete(this.onFileDeleted, this, subscriptions);
}
}
}
this._disposable = Disposable.from.apply(this, subscriptions);
}
示例10: constructor
constructor(
private readonly _normalizePath: (resource: vscode.Uri) => string | undefined
) {
super();
this._versionBarEntry = this._register(vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 99 /* to the right of editor status (100) */));
vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this, this._disposables);
}