prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Don't move cursor at the end when populating the diagnostics panel
  When the diagnostics are populated the cursor in the panel is moved to the end. See [here](https://github.com/tomv564/LSP/blob/2869978d8b46d717da27eb0ac7a7e234840b218d/plugin/core/panels.py#L53-L56).
  
  Is there a reason for this? 
  
  Because I can't use the `f4` keybinding to goto the next result when it is opened.
  Instead I need first to press the `shift + f4`, which is the backward direction.
  
  
  Here is a simple solution.
  ```diff
       def run(self, edit, characters):
           self.view.replace(edit, sublime.Region(0, self.view.size()), characters)
   
  -        # Move cursor to the end
  +        # Clear the selection
           selection = self.view.sel()
           selection.clear()
  -        selection.add(sublime.Region(self.view.size(), self.view.size()))
  ```
  
  
  </issue>
  <code>
  [start of plugin/core/panels.py]
  1 import sublime
  2 import sublime_plugin
  3 
  4 
  5 OUTPUT_PANEL_SETTINGS = {
  6     "auto_indent": False,
  7     "draw_indent_guides": False,
  8     "draw_white_space": "None",
  9     "gutter": False,
  10     'is_widget': True,
  11     "line_numbers": False,
  12     "margin": 3,
  13     "match_brackets": False,
  14     "scroll_past_end": False,
  15     "tab_size": 4,
  16     "translate_tabs_to_spaces": False,
  17     "word_wrap": False
  18 }
  19 
  20 
  21 def create_output_panel(window: sublime.Window, name: str) -> sublime.View:
  22     panel = window.create_output_panel(name)
  23     settings = panel.settings()
  24     for key, value in OUTPUT_PANEL_SETTINGS.items():
  25         settings.set(key, value)
  26     return panel
  27 
  28 
  29 def destroy_output_panels(window: sublime.Window):
  30     for panel_name in ["references", "diagnostics"]:
  31         window.destroy_output_panel(panel_name)
  32 
  33 
  34 class LspClearPanelCommand(sublime_plugin.TextCommand):
  35     """
  36     A clear_panel command to clear the error panel.
  37     """
  38 
  39     def run(self, edit):
  40         self.view.set_read_only(False)
  41         self.view.erase(edit, sublime.Region(0, self.view.size()))
  42         self.view.set_read_only(True)
  43 
  44 
  45 class LspUpdatePanelCommand(sublime_plugin.TextCommand):
  46     """
  47     A update_panel command to update the error panel with new text.
  48     """
  49 
  50     def run(self, edit, characters):
  51         self.view.replace(edit, sublime.Region(0, self.view.size()), characters)
  52 
  53         # Move cursor to the end
  54         selection = self.view.sel()
  55         selection.clear()
  56         selection.add(sublime.Region(self.view.size(), self.view.size()))
  57
  [end of plugin/core/panels.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/core/panels.py b/plugin/core/panels.py
  --- a/plugin/core/panels.py
  +++ b/plugin/core/panels.py
  @@ -50,7 +50,6 @@
       def run(self, edit, characters):
           self.view.replace(edit, sublime.Region(0, self.view.size()), characters)
   
  -        # Move cursor to the end
  +        # Clear the selection
           selection = self.view.sel()
           selection.clear()
  -        selection.add(sublime.Region(self.view.size(), self.view.size()))
  
verification_info: {"golden_diff": "diff --git a/plugin/core/panels.py b/plugin/core/panels.py\n--- a/plugin/core/panels.py\n+++ b/plugin/core/panels.py\n@@ -50,7 +50,6 @@\n     def run(self, edit, characters):\n         self.view.replace(edit, sublime.Region(0, self.view.size()), characters)\n \n-        # Move cursor to the end\n+        # Clear the selection\n         selection = self.view.sel()\n         selection.clear()\n-        selection.add(sublime.Region(self.view.size(), self.view.size()))\n", "issue": "Don't move cursor at the end when populating the diagnostics panel\nWhen the diagnostics are populated the cursor in the panel is moved to the end. See [here](https://github.com/tomv564/LSP/blob/2869978d8b46d717da27eb0ac7a7e234840b218d/plugin/core/panels.py#L53-L56).\r\n\r\nIs there a reason for this? \r\n\r\nBecause I can't use the `f4` keybinding to goto the next result when it is opened.\r\nInstead I need first to press the `shift + f4`, which is the backward direction.\r\n\r\n\r\nHere is a simple solution.\r\n```diff\r\n     def run(self, edit, characters):\r\n         self.view.replace(edit, sublime.Region(0, self.view.size()), characters)\r\n \r\n-        # Move cursor to the end\r\n+        # Clear the selection\r\n         selection = self.view.sel()\r\n         selection.clear()\r\n-        selection.add(sublime.Region(self.view.size(), self.view.size()))\r\n```\r\n\n", "before_files": [{"content": "import sublime\nimport sublime_plugin\n\n\nOUTPUT_PANEL_SETTINGS = {\n    \"auto_indent\": False,\n    \"draw_indent_guides\": False,\n    \"draw_white_space\": \"None\",\n    \"gutter\": False,\n    'is_widget': True,\n    \"line_numbers\": False,\n    \"margin\": 3,\n    \"match_brackets\": False,\n    \"scroll_past_end\": False,\n    \"tab_size\": 4,\n    \"translate_tabs_to_spaces\": False,\n    \"word_wrap\": False\n}\n\n\ndef create_output_panel(window: sublime.Window, name: str) -> sublime.View:\n    panel = window.create_output_panel(name)\n    settings = panel.settings()\n    for key, value in OUTPUT_PANEL_SETTINGS.items():\n        settings.set(key, value)\n    return panel\n\n\ndef destroy_output_panels(window: sublime.Window):\n    for panel_name in [\"references\", \"diagnostics\"]:\n        window.destroy_output_panel(panel_name)\n\n\nclass LspClearPanelCommand(sublime_plugin.TextCommand):\n    \"\"\"\n    A clear_panel command to clear the error panel.\n    \"\"\"\n\n    def run(self, edit):\n        self.view.set_read_only(False)\n        self.view.erase(edit, sublime.Region(0, self.view.size()))\n        self.view.set_read_only(True)\n\n\nclass LspUpdatePanelCommand(sublime_plugin.TextCommand):\n    \"\"\"\n    A update_panel command to update the error panel with new text.\n    \"\"\"\n\n    def run(self, edit, characters):\n        self.view.replace(edit, sublime.Region(0, self.view.size()), characters)\n\n        # Move cursor to the end\n        selection = self.view.sel()\n        selection.clear()\n        selection.add(sublime.Region(self.view.size(), self.view.size()))\n", "path": "plugin/core/panels.py"}]}