From 8ac7cefd813ea49aa9764293f96856d8157deb59 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Thu, 2 Nov 2023 14:02:06 +0100 Subject: [PATCH 1/2] Ensure new views can act as a result buffer after creation Ref: sublimehq/sublime_text#5596 Ref: sublimehq/sublime_text#1358 Directly after creation, t.i. after the views *first* activation, result regexes (e.g. `result_file_regex`) are not in effect. The work-around is to call `focus_view` *after* assigning the regexes. For now, call this unconditionally to get better insights into this side-effect. --- common/util/view.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/util/view.py b/common/util/view.py index 2cada7db0..032f29b9c 100644 --- a/common/util/view.py +++ b/common/util/view.py @@ -77,6 +77,10 @@ def create_scratch_view(window, typ, options={}): "read_only": True } update_view(view, ChainMap(options, defaults)) # type: ignore[arg-type] # mypy expects a MutableMapping here + # Call `focus_view` so that `result_file_regex` et.al. settings get applied. + # This does *not* in turn sends `on_activated` as the view gets activated + # directly after its creation. + window.focus_view(view) return view From 51cdc959b1df6a319f9cee3de49d6d313a0d2041 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Thu, 2 Nov 2023 13:54:49 +0100 Subject: [PATCH 2/2] Add type hint to remove a "type: ignore" comment --- common/util/view.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/util/view.py b/common/util/view.py index 032f29b9c..0b9937993 100644 --- a/common/util/view.py +++ b/common/util/view.py @@ -8,7 +8,7 @@ MYPY = False if MYPY: - from typing import Mapping, Optional + from typing import Callable, Mapping, Optional ############## @@ -91,12 +91,11 @@ def update_view(view, options): "title": view.set_name, "scratch": view.set_scratch, "read_only": view.set_read_only, - } - + } # type: Mapping[str, Callable] settings = view.settings() for k, v in options.items(): if k in special_setters: - special_setters[k](v) # type: ignore[operator] + special_setters[k](v) else: settings.set(k, v)