Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make panels consistent #1524

Merged
merged 16 commits into from
Dec 18, 2020
Merged

Make panels consistent #1524

merged 16 commits into from
Dec 18, 2020

Conversation

predragnikolic
Copy link
Member

This is a draft that aims to make the diagnostics, references and rename panel look the same.

Diagnostics before:
Screenshot 2020-12-12 at 16 21 48

Diagnostics after:
Screenshot 2020-12-12 at 16 23 11

References before:
Screenshot 2020-12-12 at 16 21 58

References after:
Screenshot 2020-12-12 at 16 23 18

Rename before:
Screenshot 2020-12-12 at 16 22 05

Rename after:
Screenshot 2020-12-12 at 16 23 25

Questions
  1. Should we have a \n after each as a separator between filenames?
plugin/symbols.py:
	   1:28   from .core.protocol import Request, Range
plugin/core/protocol.py:
	  98:7    class Request:

or

plugin/symbols.py:
	   1:28   from .core.protocol import Request, Range

plugin/core/protocol.py:
	  98:7    class Request:
  1. I think I can reuse the same syntax file for references to both references and rename panels? Should I delete the Rename.sublime-syntax file? Please give me a suggestion on what to do here. :)

  2. The line_regex now must contain a space in front.
    I put a \t in front of any line diagnostics, is that ok change?

@rwols
Copy link
Member

rwols commented Dec 12, 2020

Looks like a good opportunity to refactor the "rename" and "references" panel to a common builder class. We're going to need such a class anyway, as we'll also be needing to present the "callees" and "callers" from the new set of call hierarchy requests of 3.16: #1429

@predragnikolic
Copy link
Member Author

predragnikolic commented Dec 12, 2020

a common builder class

Something like this?

class Panel:
    def __init__(self, window: sublime.Window, name: str, unlisted=False):
        self.window = window
        self.panel = self.window.create_output_panel(name, unlisted)
        self.name = "output.{}".format(name)

    def is_open(self):
        return self.window.active_panel() == self.name

    def open(self):
        self.window.run_command("show_panel", {"panel": self.name})

    def hide(self):
        self.window.run_command("hide_panel", {"panel": self.name})

    def update(self, content: str):
        self.panel.run_command("lsp_update_panel", {"characters": content})

    def destroy(self):
        self.window.destroy_output_panel(self.name)

Not sure what you have envisioned :)

plugin/core/views.py Outdated Show resolved Hide resolved
plugin/core/windows.py Outdated Show resolved Hide resolved
@rwols
Copy link
Member

rwols commented Dec 12, 2020

Not sure what you have envisioned :)

A builder class... to abstract away all of the boring indent logic and formatting logic. So something like this:

class PanelBuilder:

    def preamble(self, text: str) -> None:
        """Set the preamble text"""
        ...

    def filename(self, filename: str) -> None:
        """Render a filename to the panel"""
        ...

    def diagnostic(self, diagnostic: Diagnostic) -> None:
        """Render a diagnostic to the panel"""
        ...

    def location(self, range: Dict[str, Any], identifier: Optional[str] = None) -> None:
        """Render a reference/rename location"""
        ...

    def __str__(self) -> str:
        """Flush the content as a string"""
        ...

does that make sense?

@predragnikolic
Copy link
Member Author

predragnikolic commented Dec 12, 2020

@rwols I know I haven't implemented your suggestion yet. (for the PanelBuilder)
but I wanted to build a Panel class that abstracts away the interactions with the panel api.

My question is, should I revert the 2a962e0 ?
If the abstraction is too much, or not necessary at the moment I can revert it with no problem :)

remove ensure_*_panel and ensure_panel and create_panel functions
with a class Panel that abstracts all the interaction with the panels
@predragnikolic
Copy link
Member Author

I reverted the changes 2a962e0
Can PanelBuilder also be implemented in a different PR?
I just wanted the panels to be consistent :)

@rwols
Copy link
Member

rwols commented Dec 13, 2020

1

Should we have a \n after each as a separator between filenames?

I don't see the need for it to be honest.

2

Should I delete the Rename.sublime-syntax file?

Sounds good.

3

The line_regex now must contain a space in front. I put a \t in front of any line diagnostics, is that ok change?

I don't understand why this is needed? Why doesn't SublimeLinter use a tab? http://www.sublimelinter.com/en/stable/

4

Please don't use string concatenation in windows.py

Account if a user encounters files with more the 10000 lines
- to be consistent with Sublime text find in project
- and it just gives a visual separation of the results,

although there is no need for \n between filenames, I think that they help readability
before the References.sublime-syntax would match

16 references for 'Response'
^^ number
17 changes across 6 files.
^^ number

after this commit those number won't be matched

16 references for 'Response'
17 changes across 6 files.
@predragnikolic
Copy link
Member Author

4 - is done.
3 - is done.
2 - is done.
1 - Although a \n is not necessary I would argue that a new line gives a visual separation of the results which help readability. Because of that I would keep the \n between filenames. :)

@predragnikolic predragnikolic marked this pull request as ready for review December 16, 2020 20:24
increment the row to account the \n for the spacing between filenames
so that the phantoms appear at the right place

Co-authored-by @rwols
Co-authored-by @rchl
@rwols rwols merged commit a9406f5 into st4000-exploration Dec 18, 2020
@rwols rwols deleted the make-panels-consistent branch December 18, 2020 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants