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


TypeScript window.onDidChangeActiveTextEditor方法代码示例

本文整理汇总了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));
}
开发者ID:alloy,项目名称:vscode-clang,代码行数:33,代码来源:extension.ts

示例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);
			});
		});
	});
开发者ID:mrmlnc,项目名称:vscode-lebab,代码行数:30,代码来源:extension.ts

示例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;
	});
}
开发者ID:1424667164,项目名称:vscode,代码行数:26,代码来源:typescriptMain.ts

示例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();
}
开发者ID:cozmo,项目名称:vimish,代码行数:27,代码来源:extension.ts

示例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();
	}
}
开发者ID:scytalezero,项目名称:vscode-npm-scripts,代码行数:30,代码来源:main.ts

示例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);
    }
  }));

}
开发者ID:rtorr,项目名称:vscode-flow,代码行数:33,代码来源:diagnostics.ts

示例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);
}
开发者ID:isidorn,项目名称:diagnostics,代码行数:30,代码来源:extension.ts

示例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);
}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:27,代码来源:linters.ts

示例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);
    }
开发者ID:hoovercj,项目名称:vscode-perforce,代码行数:32,代码来源:FileSystemListener.ts

示例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);
	}
开发者ID:PKRoma,项目名称:vscode,代码行数:7,代码来源:versionStatus.ts


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