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

Minimap: support // Mark meta comments to support custom rendering in the minimap #74843

Closed
pvinis opened this issue Jun 4, 2019 · 44 comments
Closed
Assignees
Labels
editor-minimap Code/Text minimap widget issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@pvinis
Copy link

pvinis commented Jun 4, 2019

Take a look at the minimap of Xcode 11.
Screenshot 2019-06-04 at 14 42 13

  • Nice and clean rectangles in the right size
  • Colors from the syntax highlighting
  • Titles/separators coming from // MARK: UISceneSession Lifecycle in this case, but it can be used in a bunch more languages
@vscodebot vscodebot bot added the editor-minimap Code/Text minimap widget issues label Jun 4, 2019
@egamma egamma added the info-needed Issue requires more information from poster label Jun 4, 2019
@egamma
Copy link
Member

egamma commented Jun 4, 2019

Have you tried the setting editor.minimap.renderCharacters to false?

Suggest to file a separate issue for separator support in the minimap.

@pvinis
Copy link
Author

pvinis commented Jun 5, 2019

Hm nice. That fixed the nice and clean rectangles :D not great in size still. Also the colors I guess are correct too.

So actually what this issue is, is a way to configure the size of the rects, and the support for // MARK style separators.

@egamma egamma self-assigned this Jun 11, 2019
@szotp
Copy link

szotp commented Jun 15, 2019

Perhaps this could also support class and method names from file outline.

@egamma egamma changed the title Prettier minimap Minimap: support // Mark meta comments to support custom rendering in the minimap Jun 21, 2019
@egamma egamma added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Jun 21, 2019
@egamma egamma removed their assignment Jun 21, 2019
@RMacfarlane RMacfarlane added this to the Backlog Candidates milestone Oct 24, 2019
@rldaulton
Copy link

Ever since the release of XCode 11, I've wanted this. Really hoping this issue becomes a reality!

@vscodebot
Copy link

vscodebot bot commented Jan 15, 2020

🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodebot vscodebot bot modified the milestones: Backlog Candidates, Backlog Jan 15, 2020
@mrousavy
Copy link

Can't find this in the backlog, is it already implemented in the current release? 🤔

@gcamp806
Copy link

I found it in the backlog. So glad this will be worked on!!

@mrousavy
Copy link

@gcamp806 do you have a link for the issue in the backlog?

@gcamp806
Copy link

@mrousavy the link on the backlog brings you back to this page... On the backlog page, I searched for "Mark meta" and had to keep scrolling for github to load more of the page. The issues are sorted by creation date, so scroll down to June 2019 and you should be able to see it.

@andyjeffries
Copy link

Any update on this? I keep thinking I'd really like to have this in VS Code...

@githubUnknownUser
Copy link

I'm looking forward to this one!

@sophiagatliff
Copy link

yes definitely want //MARKs! Super helpful.

@RMacfarlane RMacfarlane removed their assignment May 12, 2021
@netgfx
Copy link

netgfx commented May 30, 2021

any info about this? It is really helpful especially in large files

@nxcco
Copy link

nxcco commented Jun 24, 2021

Is there any progress after 2 years?

@andyjeffries
Copy link

Not that I've seen. Super frustrating... I even tweeted saying I'd be happy doing the work on it if someone could point me in the right direction. https://twitter.com/andyjeffries/status/1399768200557088770

@andyjeffries
Copy link

Just to try to get some visibility, the main people that seem to have worked on the minimap are @alexdima and @RMacfarlane. Maybe tagging them may get the right eyes on this issue. Again, I've never used Typescript but I'm happy jumping in to help if I can just get some pointers on how to do it? Architecture guides on the minimap or VS Code in general? Any ideas for how you'd implement it, if you had time, etc.

@travisbader
Copy link

Bummer this has gone stale, would be a great feature

@ffernn-dev
Copy link

Still nothing on this? Would love to see it

@maxfierrog
Copy link

Coming from Xcode back to this and seeing that it still not up made my day a very sad one.

@reececomo
Copy link

It would be game changing to have rendered headings for - MARK:, pragma and //#region. Minimap hasn't received much love 🥲

Currently using the Colored Regions plugin as a workaround, but would be amazing to finally see support for this added.

@glowcap
Copy link

glowcap commented Aug 12, 2023

Adding to this thread in hopes someone gets around to it. At this point, I'm almost bitter that there's anything in Xcode that I prefer over VSCode

@andyjeffries
Copy link

Me too, particularly bitter when I've already offered to help in doing it. I'll learn enough TypeScript to get it done. I just need a pointer in where in the codebase to start looking for it...

@dgileadi
Copy link
Contributor

Me too, particularly bitter when I've already offered to help in doing it. I'll learn enough TypeScript to get it done. I just need a pointer in where in the codebase to start looking for it...

I'm not a vscode developer but I have done some work to try to get this running. I don't have dedicated time to give to this so progress is slow and may fail entirely. In any case I can help point to where in the code to look.

The first main task seems to be detecting what should be displayed as a "section header" (which is what I'm calling the things that should be visible text in the minimap). I wrote some yet-untested code that uses vscode's built-in region regexes to detect region starts. I'm getting these regexes via LanguageConfigurationService.getLanguageConfiguration(languageId).foldingRules. Note that a single document may contain multiple languages, so the language ID comes from ITextModel.getLanguageIdAtPosition(lineNumber, 0) using the current line number. I also wrote yet-untested code for detecting MARK: comments with a simple regex. The main challenge here is detecting whether the line starts with a comment, and I do that by using ITextModel.tokenization.getLineTokens(lineNumber), checking whether the first non-whitespace token is a comment, and then running the MARK: regex on the rest of the line if so.

The next main task seems to be rendering the section headers in the minimap as readable text. The minimap is coded to expect lines that are all the same height, which was quite reasonable until this change, and to render those lines using cached bitmapped font characters. These get rendered to an ImageData and when the view changes only the necessary bits get re-rendered. This means that it's not super straightforward to add section headers since it's content with a different height and a different rendering method. In any case the starting point for all this rendering code is in minimap.ts.

There are also some new configuration options that will likely be needed, and they live in more than one place. Search the codebase for minimapLineHeight and you'll find where to put them.

Since someone will probably ask, I've pushed my changes to a branch. I'm well aware that my code is incorrect in some places (particularly my rendering code) and it currently doesn't even compile, so trying to run it will only end in tears.

@dgileadi
Copy link
Contributor

I made a PR but I guess I neglected to mention it in this issue. The minimap looks like the following with my PR:
vscode-minimap

@andyjeffries
Copy link

This looks absolutely epic @dgileadi !!! I assume it works with every language? (that reports comments as a syntax type)

@andyjeffries
Copy link

I don't know where comments should go, here or on the PR. I'll comment on the PR side though. Not working with one highlighting language.

@alexdima alexdima self-assigned this Mar 18, 2024
@alexdima alexdima modified the milestones: Backlog, March 2024 Mar 18, 2024
alexdima added a commit that referenced this issue Mar 18, 2024
* WIP for adding minimap section headers for #74843

* Get section headers rendering

* Fix default value of section header font size

* Fix tests

* Improve section header position

* Fix separator display, update after config change

* Split too-long headers with an ellipsis

* Render section headers on the decorations canvas

* Support MARK with just a separator line

* Calculate minimap section headers asynchronously

* Simplify change

* Avoid font variable duplication

* Fix issue introduced earlier

* Recompute section headers when the language configuration changes

* Fix problem in constructing region header range

* Parse mark headers in the entire file and then filter out the ones not appearing in comments on the UI side, where tokens info is available

---------

Co-authored-by: Alexandru Dima <alexdima@microsoft.com>
@andyjeffries
Copy link

Wanted to publicly thank @dgileadi for this work!!! Been a strong advocate of it for ages, and I'm so grateful for his efforts in the original PR, the reworked version and then keeping it up to date while waiting for it to be merged. Thank you!

chen-ky pushed a commit to chen-ky/vscode that referenced this issue Mar 18, 2024
* WIP for adding minimap section headers for microsoft#74843

* Get section headers rendering

* Fix default value of section header font size

* Fix tests

* Improve section header position

* Fix separator display, update after config change

* Split too-long headers with an ellipsis

* Render section headers on the decorations canvas

* Support MARK with just a separator line

* Calculate minimap section headers asynchronously

* Simplify change

* Avoid font variable duplication

* Fix issue introduced earlier

* Recompute section headers when the language configuration changes

* Fix problem in constructing region header range

* Parse mark headers in the entire file and then filter out the ones not appearing in comments on the UI side, where tokens info is available

---------

Co-authored-by: Alexandru Dima <alexdima@microsoft.com>
@alexdima
Copy link
Member

Thank you @dgileadi !

@alexdima alexdima added the verification-needed Verification of issue is requested label Mar 27, 2024
@dgileadi
Copy link
Contributor

Thank you @dgileadi !

You're most welcome—thank you for helping it get all the way there!

@TylerLeonhardt
Copy link
Member

Just stumbled upon this feature yesterday and really love it!
image

Thanks @dgileadi!

@melroy89
Copy link

Thank you @dgileadi!

@melroy89
Copy link

One more thing.. what about also showing TODO:? Wouldn't that be great as well??

@dgileadi
Copy link
Contributor

I think it would be awesome if there were an extension point for contributing "section header" items to the sidebar, but I didn't want to push this to be too complicated—it was already a lot of work to get this change in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-minimap Code/Text minimap widget issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests