Skip to content

active_view() returns view without input focus #6817

@iccir

Description

@iccir

Description of the bug

Consider the following Listener:

class Listener(sublime_plugin.EventListener):
    def on_activated(self, view: sublime.View):
        print("on_activated", view, view.window().active_view())

I would expect the view to always be equal to that returned by active_view(). I would also expect active_view() to return the view with the text cursor. However, active_view() seems to ignore text fields, console I/O panels, etc.

If I click on the console input text field, I get:

on_activated View(86) View(67)

If I pull up a Quick Panel, I see:

on_activated View(55) View(67)

Steps to reproduce

  1. Make a plugin with the above Listener example.
  2. Open the console
  3. Notice that there is a mismatch in the active views

Expected behavior

active_view() should return the active view, as indicated by the text cursor.

Actual behavior

active_view() ignores the console input fields, quick panel input field, console output, output panels, etc.

Sublime Text build number

4200

Operating system & version

macOS 14.7

(Linux) Desktop environment and/or window manager

No response

Additional information

To be clear: on_activated() is doing what I need it to do (return the View with the cursor / input focus), active_view() is not. Please do not fix this by changing the behavior of on_activated().

I recognize that changing active_view() might break existing plug-ins. Perhaps there should be an optional "include_elements" parameter that defaults to the old behavior:

def active_view(self, include_elements=False)

OpenGL context information


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions