oleg-shilo / sublime-codemap

CodeMap - is a ST3 plugin for showing the code tree representing the code structure of the active view/document
MIT License
41 stars 4 forks source link

Use transient sheets #43

Open kapitanluffy opened 1 week ago

kapitanluffy commented 1 week ago

This would be awesome if you can use transient sheets

Here's an example image

oleg-shilo commented 1 week ago

Can you elaborate, please?

kapitanluffy commented 1 week ago

This is only a feature suggestion. From what I understood, you are using groups. sublime can now show a "transient" sheet. This sheet acts like a preview that appears to the right of the current active view, like a sidebar. In my screenshot, you can see there's another sheet on the right.

This way, you won't be interfering with people whose workflow lies heavily on groups. For example, I am a dev that always want to see two files at once so I have 2 column groups in my setup. Installing codemap will break that.

oleg-shilo commented 1 week ago

OK, it makes sense. Thank you. I was not aware of this new feature. When this package was created (7 years ago) groups were the only way to mimic the IDE layout. Will have a look.

oleg-shilo commented 1 week ago

Hm... I might have misunderstood your proposal.

I have a look at TRANSIENT and judging from the description it does not give the user anything new except it does not assign a tab to it.

A quick test with a hello-world style plugin showed no UX as you described: (I could not find ane example so it is what ChatGPT suggested)

def run(self, edit):
    # Define the content to display in the transient view
    content = "This is a transient view!\nClose by clicking outside or pressing Esc."

    # Create a new transient view
    transient_view = self.view.window().new_file(flags=sublime.TRANSIENT)

    # Set the view's name and insert content
    transient_view.set_name("Transient Preview")
    transient_view.run_command("insert_content", {"content": content})

    # Set the view to scratch, so Sublime won't prompt to save it
    transient_view.set_scratch(True)

The new tap appears as normal. BTW Escape or clicking outside does not close it. From the user's point of view, it's just another document.
Am I missing something?

. . .

Theoretically, TRANSIENT can assist in showing some content without a real file behind it. But this is something that is already solved in CodMap.

... interfering with people whose workflow lies heavily on groups.

I think this is the problem that you are trying to solve. But I am not sure it is a problem. CodeMap view is only inserted in an additional group when it's made visible. After that, you can freely move it to any other group and it will simply show the map of the currently active view regardless of which group it belongs to. image

If the user prefers never to have more than 1 group, then indeed CodeMap interferes. But I am not sure you are referring to this.

So it is either I do not interpret correctly what TRANSIENT means in this context or we are not aligned on the desired UX.

kapitanluffy commented 6 days ago

My bad. I meant SEMI_TRANSIENT, here's how I do mine

self.window.open_file(
            filepath,
            sublime.ENCODED_POSITION + sublime.FORCE_GROUP + sublime.FORCE_CLONE + sublime.SEMI_TRANSIENT + sublime.ADD_TO_SELECTION
        )
oleg-shilo commented 3 days ago

Thank you, I tested your code and it seems not to "appear to the right of the current active view, like a sidebar" but rather replace the current view with the transient one. It also does not suspend the tab as I thought. Though TRANSIENT does.

capture2

If it is what you had in mind then I am not sure it fits the intended UX, which is to mimic all major IDEs by providing side by side layout for the active document and its document outline view (CodeMap view). Thus CodeMap stays visible (until user closes it) and reflects the structure of the currently active document.

kapitanluffy commented 1 day ago

Looking at my code. I guess the difference is that I run the command on the new view. I uploaded my plugin here. You should where I used it in open_line.py. Sorry for the late replies 😅