Repository: sublimelsp/LSP

Issue:
LSP needs a LspJumpBackCommand
When executing LSP goto definition, 
and then executing the built in `jump_back` command, 
the cursor won't be placed in the previous place, as I expect.

To fix this, we can introduce a `LspJumpBackCommand`.
We can do the same thing as TernForSublime [did](https://github.com/ternjs/tern_for_sublime/blob/91a27a39b1b0a33a9043aa685e1ee48c64a58274/tern.py#L564).  


Discussion:
Where is the cursor currently restored to when jumping back? Is this within a file or between files?
`ctrl+shift+d` - Lsp `lsp_symbol_definition` command.
`ctrl+shift+s` - Sublime built in `jump_back` command.

> Where is the cursor currently restored to when jumping back? 

![recorded](https://user-images.githubusercontent.com/22029477/50398864-4aded480-077b-11e9-81ef-46a85304ee0e.gif)

The jump_back command doesn't keep track that we did a lsp_symbol_definition.

Solution
Create a `LspJumpBackCommand` that would pop from `jump_back_history_stack` and  append to it when we trigger `lsp_symbol_definition`.

I'd really really like to figure out how to make this work with Sublime's built-in `jump_back` instead of Tern's solution - this adds complexity to us (managing our own stack) and the user (_two_ ways to jump back).

In these release notes the jump back feature should specifically work with `goto_definition`. 
https://www.sublimetext.com/blog/articles/sublime-text-3-beta-3019

Looking at sublime's built-in python code, I found some special handling for `goto_definition` here: 
https://github.com/twolfson/sublime-files/blob/d5f4835f43a9822a59e19d6bce26a5b2fd41273c/Packages/Default/history_list.py#L203

Can our solution be inspired by that instead? Is there a "published API" way to push a selection to the stack in our own `lsp_symbol_definition` ?
And you are right.
Here is the minimal code I could come up with for this to work
```python
from Default.history_list import get_jump_history_for_view

class LspSymbolDefinitoionListener(sublime_plugin.ViewEventListener):
    def on_text_command(self, command_name, args):
        if command_name == 'lsp_symbol_definition':
            if not self.view.settings().get('is_widget'):
                get_jump_history_for_view(self.view).push_selection(self.view)
```
Nice, perhaps LspSymbolDefinitionCommand can take care of this? Want to do a PR?

Resolving patch:
diff --git a/plugin/definition.py b/plugin/definition.py
--- a/plugin/definition.py
+++ b/plugin/definition.py
@@ -5,6 +5,7 @@
 from .core.documents import get_document_position, get_position, is_at_word
 from .core.url import uri_to_filename
 from .core.logging import debug
+from Default.history_list import get_jump_history_for_view  # type: ignore
 try:
     from typing import List, Dict, Optional, Any
     assert List and Dict and Optional and Any
@@ -34,6 +35,9 @@ def run(self, edit, event=None) -> None:
     def handle_response(self, response: 'Optional[Any]', position) -> None:
         window = sublime.active_window()
         if response:
+            # save to jump back history
+            get_jump_history_for_view(self.view).push_selection(self.view)
+
             location = response if isinstance(response, dict) else response[0]
             file_path = uri_to_filename(location.get("uri"))
             start = Point.from_lsp(location['range']['start'])


Test patch: