We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Goto Definition throws
**Describe the bug**
Using `LSP-pyright`, click `Definition`. Nothing will happen visually.

**To Reproduce**
1. `LSP-pyright`
2. hover over something
3. click `Definition` (or `Type Definition` or `Declaration`)
4. see error in console: 
```py
Traceback (most recent call last):
  File "D:\Programs\Sublime Text 4\Data\Installed Packages\LSP.sublime-package\plugin/core/sessions.py", line 1681, in <lambda>
  File "D:\Programs\Sublime Text 4\Data\Installed Packages\LSP.sublime-package\plugin/core/open.py", line 96, in open_file
  File "D:\Programs\Sublime Text 4\Data\Installed Packages\LSP.sublime-package\plugin/core/open.py", line 82, in _find_open_file
TypeError: find_open_file() takes 2 positional arguments but 3 were given
```

**Expected behavior**
no error, I go to definition

**Environment (please complete the following information):**
- OS: windows
- Sublime Text version: 4121
- LSP version: 1.28.0
- Language servers used: pyright-1.2.42


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugin/core/open.py`
Content:
```
1 from .logging import exception_log
2 from .promise import Promise
3 from .promise import ResolveFunc
4 from .protocol import DocumentUri
5 from .protocol import Range
6 from .protocol import UINT_MAX
7 from .typing import Dict, Tuple, Optional
8 from .typing import cast
9 from .url import parse_uri
10 from .views import range_to_region
11 from urllib.parse import unquote, urlparse
12 import os
13 import re
14 import sublime
15 import sublime_plugin
16 import subprocess
17 import webbrowser
18 
19 
20 opening_files = {}  # type: Dict[str, Tuple[Promise[Optional[sublime.View]], ResolveFunc[Optional[sublime.View]]]]
21 FRAGMENT_PATTERN = re.compile(r'^L?(\d+)(?:,(\d+))?(?:-L?(\d+)(?:,(\d+))?)?')
22 
23 
24 def lsp_range_from_uri_fragment(fragment: str) -> Optional[Range]:
25     match = FRAGMENT_PATTERN.match(fragment)
26     if match:
27         selection = {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}  # type: Range
28         # Line and column numbers in the fragment are assumed to be 1-based and need to be converted to 0-based
29         # numbers for the LSP Position structure.
30         start_line, start_column, end_line, end_column = [max(0, int(g) - 1) if g else None for g in match.groups()]
31         if start_line:
32             selection['start']['line'] = start_line
33             selection['end']['line'] = start_line
34         if start_column:
35             selection['start']['character'] = start_column
36             selection['end']['character'] = start_column
37         if end_line:
38             selection['end']['line'] = end_line
39             selection['end']['character'] = UINT_MAX
40         if end_column is not None:
41             selection['end']['character'] = end_column
42         return selection
43     return None
44 
45 
46 def open_file_uri(
47     window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1
48 ) -> Promise[Optional[sublime.View]]:
49 
50     decoded_uri = unquote(uri)  # decode percent-encoded characters
51     parsed = urlparse(decoded_uri)
52     open_promise = open_file(window, decoded_uri, flags, group)
53     if parsed.fragment:
54         selection = lsp_range_from_uri_fragment(parsed.fragment)
55         if selection:
56             return open_promise.then(lambda view: _select_and_center(view, cast(Range, selection)))
57     return open_promise
58 
59 
60 def _select_and_center(view: Optional[sublime.View], r: Range) -> Optional[sublime.View]:
61     if view:
62         return center_selection(view, r)
63     return None
64 
65 
66 def _return_existing_view(flags: int, existing_view_group: int, active_group: int, specified_group: int) -> bool:
67     if specified_group > -1:
68         return existing_view_group == specified_group
69     if bool(flags & (sublime.ADD_TO_SELECTION | sublime.REPLACE_MRU)):
70         return False
71     if existing_view_group == active_group:
72         return True
73     return not bool(flags & sublime.FORCE_GROUP)
74 
75 
76 def _find_open_file(window: sublime.Window, fname: str, group: int = -1) -> Optional[sublime.View]:
77     """A replacement for Window.find_open_file that prefers the active view instead of the leftmost one."""
78     _group = window.active_group() if group == -1 else group
79     view = window.active_view_in_group(_group)
80     if view and fname == view.file_name():
81         return view
82     return window.find_open_file(fname, group)
83 
84 
85 def open_file(
86     window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1
87 ) -> Promise[Optional[sublime.View]]:
88     """
89     Open a file asynchronously.
90     It is only safe to call this function from the UI thread.
91     The provided uri MUST be a file URI
92     """
93     file = parse_uri(uri)[1]
94     # window.open_file brings the file to focus if it's already opened, which we don't want (unless it's supposed
95     # to open as a separate view).
96     view = _find_open_file(window, file)
97     if view and _return_existing_view(flags, window.get_view_index(view)[0], window.active_group(), group):
98         return Promise.resolve(view)
99 
100     was_already_open = view is not None
101     view = window.open_file(file, flags, group)
102     if not view.is_loading():
103         if was_already_open and (flags & sublime.SEMI_TRANSIENT):
104             # workaround bug https://github.com/sublimehq/sublime_text/issues/2411 where transient view might not get
105             # its view listeners initialized.
106             sublime_plugin.check_view_event_listeners(view)  # type: ignore
107         # It's already loaded. Possibly already open in a tab.
108         return Promise.resolve(view)
109 
110     # Is the view opening right now? Then return the associated unresolved promise
111     for fn, value in opening_files.items():
112         if fn == file or os.path.samefile(fn, file):
113             # Return the unresolved promise. A future on_load event will resolve the promise.
114             return value[0]
115 
116     # Prepare a new promise to be resolved by a future on_load event (see the event listener in main.py)
117     def fullfill(resolve: ResolveFunc[Optional[sublime.View]]) -> None:
118         global opening_files
119         # Save the promise in the first element of the tuple -- except we cannot yet do that here
120         opening_files[file] = (None, resolve)  # type: ignore
121 
122     promise = Promise(fullfill)
123     tup = opening_files[file]
124     # Save the promise in the first element of the tuple so that the for-loop above can return it
125     opening_files[file] = (promise, tup[1])
126     return promise
127 
128 
129 def center_selection(v: sublime.View, r: Range) -> sublime.View:
130     selection = range_to_region(r, v)
131     v.run_command("lsp_selection_set", {"regions": [(selection.a, selection.a)]})
132     window = v.window()
133     if window:
134         window.focus_view(v)
135     if int(sublime.version()) >= 4124:
136         v.show_at_center(selection.begin(), animate=False)
137     else:
138         # TODO: remove later when a stable build lands
139         v.show_at_center(selection.begin())  # type: ignore
140     return v
141 
142 
143 def open_in_browser(uri: str) -> None:
144     # NOTE: Remove this check when on py3.8.
145     if not uri.lower().startswith(("http://", "https://")):
146         uri = "https://" + uri
147     if not webbrowser.open(uri):
148         sublime.status_message("failed to open: " + uri)
149 
150 
151 def open_externally(uri: str, take_focus: bool) -> bool:
152     """
153     A blocking function that invokes the OS's "open with default extension"
154     """
155     try:
156         # TODO: handle take_focus
157         if sublime.platform() == "windows":
158             os.startfile(uri)  # type: ignore
159         elif sublime.platform() == "osx":
160             subprocess.check_call(("/usr/bin/open", uri))
161         else:  # linux
162             subprocess.check_call(("xdg-open", uri))
163         return True
164     except Exception as ex:
165         exception_log("Failed to open {}".format(uri), ex)
166         return False
167
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugin/core/open.py b/plugin/core/open.py
--- a/plugin/core/open.py
+++ b/plugin/core/open.py
@@ -1,3 +1,4 @@
+from .constants import ST_VERSION
 from .logging import exception_log
 from .promise import Promise
 from .promise import ResolveFunc
@@ -79,7 +80,7 @@
     view = window.active_view_in_group(_group)
     if view and fname == view.file_name():
         return view
-    return window.find_open_file(fname, group)
+    return window.find_open_file(fname, group) if ST_VERSION >= 4136 else window.find_open_file(fname)
 
 
 def open_file(

{"golden_diff": "diff --git a/plugin/core/open.py b/plugin/core/open.py\n--- a/plugin/core/open.py\n+++ b/plugin/core/open.py\n@@ -1,3 +1,4 @@\n+from .constants import ST_VERSION\n from .logging import exception_log\n from .promise import Promise\n from .promise import ResolveFunc\n@@ -79,7 +80,7 @@\n     view = window.active_view_in_group(_group)\n     if view and fname == view.file_name():\n         return view\n-    return window.find_open_file(fname, group)\n+    return window.find_open_file(fname, group) if ST_VERSION >= 4136 else window.find_open_file(fname)\n \n \n def open_file(\n", "issue": "Goto Definition throws\n**Describe the bug**\r\nUsing `LSP-pyright`, click `Definition`. Nothing will happen visually.\r\n\r\n**To Reproduce**\r\n1. `LSP-pyright`\r\n2. hover over something\r\n3. click `Definition` (or `Type Definition` or `Declaration`)\r\n4. see error in console: \r\n```py\r\nTraceback (most recent call last):\r\n  File \"D:\\Programs\\Sublime Text 4\\Data\\Installed Packages\\LSP.sublime-package\\plugin/core/sessions.py\", line 1681, in <lambda>\r\n  File \"D:\\Programs\\Sublime Text 4\\Data\\Installed Packages\\LSP.sublime-package\\plugin/core/open.py\", line 96, in open_file\r\n  File \"D:\\Programs\\Sublime Text 4\\Data\\Installed Packages\\LSP.sublime-package\\plugin/core/open.py\", line 82, in _find_open_file\r\nTypeError: find_open_file() takes 2 positional arguments but 3 were given\r\n```\r\n\r\n**Expected behavior**\r\nno error, I go to definition\r\n\r\n**Environment (please complete the following information):**\r\n- OS: windows\r\n- Sublime Text version: 4121\r\n- LSP version: 1.28.0\r\n- Language servers used: pyright-1.2.42\r\n\n", "before_files": [{"content": "from .logging import exception_log\nfrom .promise import Promise\nfrom .promise import ResolveFunc\nfrom .protocol import DocumentUri\nfrom .protocol import Range\nfrom .protocol import UINT_MAX\nfrom .typing import Dict, Tuple, Optional\nfrom .typing import cast\nfrom .url import parse_uri\nfrom .views import range_to_region\nfrom urllib.parse import unquote, urlparse\nimport os\nimport re\nimport sublime\nimport sublime_plugin\nimport subprocess\nimport webbrowser\n\n\nopening_files = {}  # type: Dict[str, Tuple[Promise[Optional[sublime.View]], ResolveFunc[Optional[sublime.View]]]]\nFRAGMENT_PATTERN = re.compile(r'^L?(\\d+)(?:,(\\d+))?(?:-L?(\\d+)(?:,(\\d+))?)?')\n\n\ndef lsp_range_from_uri_fragment(fragment: str) -> Optional[Range]:\n    match = FRAGMENT_PATTERN.match(fragment)\n    if match:\n        selection = {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}  # type: Range\n        # Line and column numbers in the fragment are assumed to be 1-based and need to be converted to 0-based\n        # numbers for the LSP Position structure.\n        start_line, start_column, end_line, end_column = [max(0, int(g) - 1) if g else None for g in match.groups()]\n        if start_line:\n            selection['start']['line'] = start_line\n            selection['end']['line'] = start_line\n        if start_column:\n            selection['start']['character'] = start_column\n            selection['end']['character'] = start_column\n        if end_line:\n            selection['end']['line'] = end_line\n            selection['end']['character'] = UINT_MAX\n        if end_column is not None:\n            selection['end']['character'] = end_column\n        return selection\n    return None\n\n\ndef open_file_uri(\n    window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1\n) -> Promise[Optional[sublime.View]]:\n\n    decoded_uri = unquote(uri)  # decode percent-encoded characters\n    parsed = urlparse(decoded_uri)\n    open_promise = open_file(window, decoded_uri, flags, group)\n    if parsed.fragment:\n        selection = lsp_range_from_uri_fragment(parsed.fragment)\n        if selection:\n            return open_promise.then(lambda view: _select_and_center(view, cast(Range, selection)))\n    return open_promise\n\n\ndef _select_and_center(view: Optional[sublime.View], r: Range) -> Optional[sublime.View]:\n    if view:\n        return center_selection(view, r)\n    return None\n\n\ndef _return_existing_view(flags: int, existing_view_group: int, active_group: int, specified_group: int) -> bool:\n    if specified_group > -1:\n        return existing_view_group == specified_group\n    if bool(flags & (sublime.ADD_TO_SELECTION | sublime.REPLACE_MRU)):\n        return False\n    if existing_view_group == active_group:\n        return True\n    return not bool(flags & sublime.FORCE_GROUP)\n\n\ndef _find_open_file(window: sublime.Window, fname: str, group: int = -1) -> Optional[sublime.View]:\n    \"\"\"A replacement for Window.find_open_file that prefers the active view instead of the leftmost one.\"\"\"\n    _group = window.active_group() if group == -1 else group\n    view = window.active_view_in_group(_group)\n    if view and fname == view.file_name():\n        return view\n    return window.find_open_file(fname, group)\n\n\ndef open_file(\n    window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1\n) -> Promise[Optional[sublime.View]]:\n    \"\"\"\n    Open a file asynchronously.\n    It is only safe to call this function from the UI thread.\n    The provided uri MUST be a file URI\n    \"\"\"\n    file = parse_uri(uri)[1]\n    # window.open_file brings the file to focus if it's already opened, which we don't want (unless it's supposed\n    # to open as a separate view).\n    view = _find_open_file(window, file)\n    if view and _return_existing_view(flags, window.get_view_index(view)[0], window.active_group(), group):\n        return Promise.resolve(view)\n\n    was_already_open = view is not None\n    view = window.open_file(file, flags, group)\n    if not view.is_loading():\n        if was_already_open and (flags & sublime.SEMI_TRANSIENT):\n            # workaround bug https://github.com/sublimehq/sublime_text/issues/2411 where transient view might not get\n            # its view listeners initialized.\n            sublime_plugin.check_view_event_listeners(view)  # type: ignore\n        # It's already loaded. Possibly already open in a tab.\n        return Promise.resolve(view)\n\n    # Is the view opening right now? Then return the associated unresolved promise\n    for fn, value in opening_files.items():\n        if fn == file or os.path.samefile(fn, file):\n            # Return the unresolved promise. A future on_load event will resolve the promise.\n            return value[0]\n\n    # Prepare a new promise to be resolved by a future on_load event (see the event listener in main.py)\n    def fullfill(resolve: ResolveFunc[Optional[sublime.View]]) -> None:\n        global opening_files\n        # Save the promise in the first element of the tuple -- except we cannot yet do that here\n        opening_files[file] = (None, resolve)  # type: ignore\n\n    promise = Promise(fullfill)\n    tup = opening_files[file]\n    # Save the promise in the first element of the tuple so that the for-loop above can return it\n    opening_files[file] = (promise, tup[1])\n    return promise\n\n\ndef center_selection(v: sublime.View, r: Range) -> sublime.View:\n    selection = range_to_region(r, v)\n    v.run_command(\"lsp_selection_set\", {\"regions\": [(selection.a, selection.a)]})\n    window = v.window()\n    if window:\n        window.focus_view(v)\n    if int(sublime.version()) >= 4124:\n        v.show_at_center(selection.begin(), animate=False)\n    else:\n        # TODO: remove later when a stable build lands\n        v.show_at_center(selection.begin())  # type: ignore\n    return v\n\n\ndef open_in_browser(uri: str) -> None:\n    # NOTE: Remove this check when on py3.8.\n    if not uri.lower().startswith((\"http://\", \"https://\")):\n        uri = \"https://\" + uri\n    if not webbrowser.open(uri):\n        sublime.status_message(\"failed to open: \" + uri)\n\n\ndef open_externally(uri: str, take_focus: bool) -> bool:\n    \"\"\"\n    A blocking function that invokes the OS's \"open with default extension\"\n    \"\"\"\n    try:\n        # TODO: handle take_focus\n        if sublime.platform() == \"windows\":\n            os.startfile(uri)  # type: ignore\n        elif sublime.platform() == \"osx\":\n            subprocess.check_call((\"/usr/bin/open\", uri))\n        else:  # linux\n            subprocess.check_call((\"xdg-open\", uri))\n        return True\n    except Exception as ex:\n        exception_log(\"Failed to open {}\".format(uri), ex)\n        return False\n", "path": "plugin/core/open.py"}], "after_files": [{"content": "from .constants import ST_VERSION\nfrom .logging import exception_log\nfrom .promise import Promise\nfrom .promise import ResolveFunc\nfrom .protocol import DocumentUri\nfrom .protocol import Range\nfrom .protocol import UINT_MAX\nfrom .typing import Dict, Tuple, Optional\nfrom .typing import cast\nfrom .url import parse_uri\nfrom .views import range_to_region\nfrom urllib.parse import unquote, urlparse\nimport os\nimport re\nimport sublime\nimport sublime_plugin\nimport subprocess\nimport webbrowser\n\n\nopening_files = {}  # type: Dict[str, Tuple[Promise[Optional[sublime.View]], ResolveFunc[Optional[sublime.View]]]]\nFRAGMENT_PATTERN = re.compile(r'^L?(\\d+)(?:,(\\d+))?(?:-L?(\\d+)(?:,(\\d+))?)?')\n\n\ndef lsp_range_from_uri_fragment(fragment: str) -> Optional[Range]:\n    match = FRAGMENT_PATTERN.match(fragment)\n    if match:\n        selection = {'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0}}  # type: Range\n        # Line and column numbers in the fragment are assumed to be 1-based and need to be converted to 0-based\n        # numbers for the LSP Position structure.\n        start_line, start_column, end_line, end_column = [max(0, int(g) - 1) if g else None for g in match.groups()]\n        if start_line:\n            selection['start']['line'] = start_line\n            selection['end']['line'] = start_line\n        if start_column:\n            selection['start']['character'] = start_column\n            selection['end']['character'] = start_column\n        if end_line:\n            selection['end']['line'] = end_line\n            selection['end']['character'] = UINT_MAX\n        if end_column is not None:\n            selection['end']['character'] = end_column\n        return selection\n    return None\n\n\ndef open_file_uri(\n    window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1\n) -> Promise[Optional[sublime.View]]:\n\n    decoded_uri = unquote(uri)  # decode percent-encoded characters\n    parsed = urlparse(decoded_uri)\n    open_promise = open_file(window, decoded_uri, flags, group)\n    if parsed.fragment:\n        selection = lsp_range_from_uri_fragment(parsed.fragment)\n        if selection:\n            return open_promise.then(lambda view: _select_and_center(view, cast(Range, selection)))\n    return open_promise\n\n\ndef _select_and_center(view: Optional[sublime.View], r: Range) -> Optional[sublime.View]:\n    if view:\n        return center_selection(view, r)\n    return None\n\n\ndef _return_existing_view(flags: int, existing_view_group: int, active_group: int, specified_group: int) -> bool:\n    if specified_group > -1:\n        return existing_view_group == specified_group\n    if bool(flags & (sublime.ADD_TO_SELECTION | sublime.REPLACE_MRU)):\n        return False\n    if existing_view_group == active_group:\n        return True\n    return not bool(flags & sublime.FORCE_GROUP)\n\n\ndef _find_open_file(window: sublime.Window, fname: str, group: int = -1) -> Optional[sublime.View]:\n    \"\"\"A replacement for Window.find_open_file that prefers the active view instead of the leftmost one.\"\"\"\n    _group = window.active_group() if group == -1 else group\n    view = window.active_view_in_group(_group)\n    if view and fname == view.file_name():\n        return view\n    return window.find_open_file(fname, group) if ST_VERSION >= 4136 else window.find_open_file(fname)\n\n\ndef open_file(\n    window: sublime.Window, uri: DocumentUri, flags: int = 0, group: int = -1\n) -> Promise[Optional[sublime.View]]:\n    \"\"\"\n    Open a file asynchronously.\n    It is only safe to call this function from the UI thread.\n    The provided uri MUST be a file URI\n    \"\"\"\n    file = parse_uri(uri)[1]\n    # window.open_file brings the file to focus if it's already opened, which we don't want (unless it's supposed\n    # to open as a separate view).\n    view = _find_open_file(window, file)\n    if view and _return_existing_view(flags, window.get_view_index(view)[0], window.active_group(), group):\n        return Promise.resolve(view)\n\n    was_already_open = view is not None\n    view = window.open_file(file, flags, group)\n    if not view.is_loading():\n        if was_already_open and (flags & sublime.SEMI_TRANSIENT):\n            # workaround bug https://github.com/sublimehq/sublime_text/issues/2411 where transient view might not get\n            # its view listeners initialized.\n            sublime_plugin.check_view_event_listeners(view)  # type: ignore\n        # It's already loaded. Possibly already open in a tab.\n        return Promise.resolve(view)\n\n    # Is the view opening right now? Then return the associated unresolved promise\n    for fn, value in opening_files.items():\n        if fn == file or os.path.samefile(fn, file):\n            # Return the unresolved promise. A future on_load event will resolve the promise.\n            return value[0]\n\n    # Prepare a new promise to be resolved by a future on_load event (see the event listener in main.py)\n    def fullfill(resolve: ResolveFunc[Optional[sublime.View]]) -> None:\n        global opening_files\n        # Save the promise in the first element of the tuple -- except we cannot yet do that here\n        opening_files[file] = (None, resolve)  # type: ignore\n\n    promise = Promise(fullfill)\n    tup = opening_files[file]\n    # Save the promise in the first element of the tuple so that the for-loop above can return it\n    opening_files[file] = (promise, tup[1])\n    return promise\n\n\ndef center_selection(v: sublime.View, r: Range) -> sublime.View:\n    selection = range_to_region(r, v)\n    v.run_command(\"lsp_selection_set\", {\"regions\": [(selection.a, selection.a)]})\n    window = v.window()\n    if window:\n        window.focus_view(v)\n    if int(sublime.version()) >= 4124:\n        v.show_at_center(selection.begin(), animate=False)\n    else:\n        # TODO: remove later when a stable build lands\n        v.show_at_center(selection.begin())  # type: ignore\n    return v\n\n\ndef open_in_browser(uri: str) -> None:\n    # NOTE: Remove this check when on py3.8.\n    if not uri.lower().startswith((\"http://\", \"https://\")):\n        uri = \"https://\" + uri\n    if not webbrowser.open(uri):\n        sublime.status_message(\"failed to open: \" + uri)\n\n\ndef open_externally(uri: str, take_focus: bool) -> bool:\n    \"\"\"\n    A blocking function that invokes the OS's \"open with default extension\"\n    \"\"\"\n    try:\n        # TODO: handle take_focus\n        if sublime.platform() == \"windows\":\n            os.startfile(uri)  # type: ignore\n        elif sublime.platform() == \"osx\":\n            subprocess.check_call((\"/usr/bin/open\", uri))\n        else:  # linux\n            subprocess.check_call((\"xdg-open\", uri))\n        return True\n    except Exception as ex:\n        exception_log(\"Failed to open {}\".format(uri), ex)\n        return False\n", "path": "plugin/core/open.py"}]}