【问题标题】:VSCode Extension API - on scrollVSCode 扩展 API - 滚动
【发布时间】:2017-12-06 21:04:25
【问题描述】:

在 VSCode 扩展 API 中滚动时是否有检测方法。我看到的唯一可用功能是:

onDidChangeActiveTextEditor: Event<TextEditor>

onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>

onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>

onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>

onDidChangeVisibleTextEditors: Event<TextEditor[]>

onDidChangeWindowState: Event<WindowState>

onDidCloseTerminal: Event<Terminal>

我可以将此作为功能请求提交。但是有什么办法可以规避这种行为吗?

【问题讨论】:

    标签: visual-studio-code vscode-extensions


    【解决方案1】:

    VS Code 现在为此提供了一个 api:window.onDidChangeTextEditorVisibleRanges

    此事件由 TextEditorVisibleRangesChangeEvent 对象触发:

    export interface TextEditorVisibleRangesChangeEvent {
        /**
         * The text editor for which the visible ranges have changed.
         */
        textEditor: TextEditor;
    
        /**
         * The new value for the text editor's visible ranges.
         */
        visibleRanges: Range[];
    }
    

    VS Code 的markdown 预览使用这个事件来同步编辑器的滚动和markdown 预览。

    【讨论】:

    • 感谢您确认我的怀疑。我们只能拭目以待
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-26
    相关资源
    最近更新 更多