prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [regression] lsp_execute does nothing due to empty session
  Since this [commit](https://github.com/sublimelsp/LSP/commit/7d05794fa3cc4ecd3931d09a90e801addc70d9fa) the `capability` variable got deleted which means that `self.best_session(self.capability)` is unable to find session.
  
  The consequence is that [LSP-metals.sublime-commands](https://github.com/scalameta/metals-sublime/blob/master/LSP-metals.sublime-commands) aren't executed.
  
   
  
  
  </issue>
  <code>
  [start of plugin/execute_command.py]
  1 import sublime
  2 from .core.protocol import Error
  3 from .core.protocol import ExecuteCommandParams
  4 from .core.registry import LspTextCommand
  5 from .core.registry import windows
  6 from .core.typing import List, Optional, Any
  7 from .core.views import uri_from_view, offset_to_point, region_to_range, text_document_identifier
  8 
  9 
  10 class LspExecuteCommand(LspTextCommand):
  11 
  12     def run(self,
  13             edit: sublime.Edit,
  14             command_name: Optional[str] = None,
  15             command_args: Optional[List[Any]] = None,
  16             session_name: Optional[str] = None,
  17             event: Optional[dict] = None) -> None:
  18         # Handle VSCode-specific command for triggering AC/sighelp
  19         if command_name == "editor.action.triggerSuggest":
  20             # Triggered from set_timeout as suggestions popup doesn't trigger otherwise.
  21             return sublime.set_timeout(lambda: self.view.run_command("auto_complete"))
  22         if command_name == "editor.action.triggerParameterHints":
  23 
  24             def run_async() -> None:
  25                 listener = windows.listener_for_view(self.view)
  26                 if listener:
  27                     listener.do_signature_help_async(manual=False)
  28 
  29             return sublime.set_timeout_async(run_async)
  30         session = self.session_by_name(session_name) if session_name else self.best_session(self.capability)
  31         if session and command_name:
  32             if command_args:
  33                 self._expand_variables(command_args)
  34             params = {"command": command_name}  # type: ExecuteCommandParams
  35             if command_args:
  36                 params["arguments"] = command_args
  37 
  38             def handle_response(response: Any) -> None:
  39                 assert command_name
  40                 if isinstance(response, Error):
  41                     sublime.message_dialog("command {} failed. Reason: {}".format(command_name, str(response)))
  42                     return
  43                 msg = "command {} completed".format(command_name)
  44                 if response:
  45                     msg += "with response: {}".format(response)
  46                 window = self.view.window()
  47                 if window:
  48                     window.status_message(msg)
  49 
  50             session.execute_command(params, progress=True).then(handle_response)
  51 
  52     def _expand_variables(self, command_args: List[Any]) -> None:
  53         region = self.view.sel()[0]
  54         for i, arg in enumerate(command_args):
  55             if arg in ["$document_id", "${document_id}"]:
  56                 command_args[i] = text_document_identifier(self.view)
  57             if arg in ["$file_uri", "${file_uri}"]:
  58                 command_args[i] = uri_from_view(self.view)
  59             elif arg in ["$selection", "${selection}"]:
  60                 command_args[i] = self.view.substr(region)
  61             elif arg in ["$offset", "${offset}"]:
  62                 command_args[i] = region.b
  63             elif arg in ["$selection_begin", "${selection_begin}"]:
  64                 command_args[i] = region.begin()
  65             elif arg in ["$selection_end", "${selection_end}"]:
  66                 command_args[i] = region.end()
  67             elif arg in ["$position", "${position}"]:
  68                 command_args[i] = offset_to_point(self.view, region.b).to_lsp()
  69             elif arg in ["$range", "${range}"]:
  70                 command_args[i] = region_to_range(self.view, region).to_lsp()
  71
  [end of plugin/execute_command.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/plugin/execute_command.py b/plugin/execute_command.py
  --- a/plugin/execute_command.py
  +++ b/plugin/execute_command.py
  @@ -27,7 +27,7 @@
                       listener.do_signature_help_async(manual=False)
   
               return sublime.set_timeout_async(run_async)
  -        session = self.session_by_name(session_name) if session_name else self.best_session(self.capability)
  +        session = self.session_by_name(session_name if session_name else self.session_name)
           if session and command_name:
               if command_args:
                   self._expand_variables(command_args)
  
verification_info: {"golden_diff": "diff --git a/plugin/execute_command.py b/plugin/execute_command.py\n--- a/plugin/execute_command.py\n+++ b/plugin/execute_command.py\n@@ -27,7 +27,7 @@\n                     listener.do_signature_help_async(manual=False)\n \n             return sublime.set_timeout_async(run_async)\n-        session = self.session_by_name(session_name) if session_name else self.best_session(self.capability)\n+        session = self.session_by_name(session_name if session_name else self.session_name)\n         if session and command_name:\n             if command_args:\n                 self._expand_variables(command_args)\n", "issue": "[regression] lsp_execute does nothing due to empty session\nSince this [commit](https://github.com/sublimelsp/LSP/commit/7d05794fa3cc4ecd3931d09a90e801addc70d9fa) the `capability` variable got deleted which means that `self.best_session(self.capability)` is unable to find session.\r\n\r\nThe consequence is that [LSP-metals.sublime-commands](https://github.com/scalameta/metals-sublime/blob/master/LSP-metals.sublime-commands) aren't executed.\r\n\r\n \r\n\n", "before_files": [{"content": "import sublime\nfrom .core.protocol import Error\nfrom .core.protocol import ExecuteCommandParams\nfrom .core.registry import LspTextCommand\nfrom .core.registry import windows\nfrom .core.typing import List, Optional, Any\nfrom .core.views import uri_from_view, offset_to_point, region_to_range, text_document_identifier\n\n\nclass LspExecuteCommand(LspTextCommand):\n\n    def run(self,\n            edit: sublime.Edit,\n            command_name: Optional[str] = None,\n            command_args: Optional[List[Any]] = None,\n            session_name: Optional[str] = None,\n            event: Optional[dict] = None) -> None:\n        # Handle VSCode-specific command for triggering AC/sighelp\n        if command_name == \"editor.action.triggerSuggest\":\n            # Triggered from set_timeout as suggestions popup doesn't trigger otherwise.\n            return sublime.set_timeout(lambda: self.view.run_command(\"auto_complete\"))\n        if command_name == \"editor.action.triggerParameterHints\":\n\n            def run_async() -> None:\n                listener = windows.listener_for_view(self.view)\n                if listener:\n                    listener.do_signature_help_async(manual=False)\n\n            return sublime.set_timeout_async(run_async)\n        session = self.session_by_name(session_name) if session_name else self.best_session(self.capability)\n        if session and command_name:\n            if command_args:\n                self._expand_variables(command_args)\n            params = {\"command\": command_name}  # type: ExecuteCommandParams\n            if command_args:\n                params[\"arguments\"] = command_args\n\n            def handle_response(response: Any) -> None:\n                assert command_name\n                if isinstance(response, Error):\n                    sublime.message_dialog(\"command {} failed. Reason: {}\".format(command_name, str(response)))\n                    return\n                msg = \"command {} completed\".format(command_name)\n                if response:\n                    msg += \"with response: {}\".format(response)\n                window = self.view.window()\n                if window:\n                    window.status_message(msg)\n\n            session.execute_command(params, progress=True).then(handle_response)\n\n    def _expand_variables(self, command_args: List[Any]) -> None:\n        region = self.view.sel()[0]\n        for i, arg in enumerate(command_args):\n            if arg in [\"$document_id\", \"${document_id}\"]:\n                command_args[i] = text_document_identifier(self.view)\n            if arg in [\"$file_uri\", \"${file_uri}\"]:\n                command_args[i] = uri_from_view(self.view)\n            elif arg in [\"$selection\", \"${selection}\"]:\n                command_args[i] = self.view.substr(region)\n            elif arg in [\"$offset\", \"${offset}\"]:\n                command_args[i] = region.b\n            elif arg in [\"$selection_begin\", \"${selection_begin}\"]:\n                command_args[i] = region.begin()\n            elif arg in [\"$selection_end\", \"${selection_end}\"]:\n                command_args[i] = region.end()\n            elif arg in [\"$position\", \"${position}\"]:\n                command_args[i] = offset_to_point(self.view, region.b).to_lsp()\n            elif arg in [\"$range\", \"${range}\"]:\n                command_args[i] = region_to_range(self.view, region).to_lsp()\n", "path": "plugin/execute_command.py"}]}