Bug 321410 - [EditorMgmt][navigation] Provide Minimap of text in editor
Summary: [EditorMgmt][navigation] Provide Minimap of text in editor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 enhancement with 5 votes (vote)
Target Milestone: 4.9 M2   Edit
Assignee: Angelo ZERR CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
: 535450 (view as bug list)
Depends on: 366471 536206
Blocks: 535450 535664 535735 536165 536393
  Show dependency tree
 
Reported: 2010-07-30 19:00 EDT by Ludovic Aelbrecht CLA
Modified: 2018-08-19 03:16 EDT (History)
13 users (show)

See Also:


Attachments
Screenshot displaying the feature (as implemented in Sublime) (152.36 KB, image/png)
2010-07-30 19:02 EDT, Ludovic Aelbrecht CLA
no flags Details
Mockup of the Outline view 'embedded' in an editor (70.85 KB, image/png)
2010-08-17 15:25 EDT, Eric Moffatt CLA
no flags Details
Minimap (gerrit patch) demo (2.18 MB, image/gif)
2018-06-04 13:14 EDT, Angelo ZERR CLA
no flags Details
Screenshot - Minimap on Linux (452.64 KB, image/png)
2018-06-05 06:01 EDT, Lars Vogel CLA
no flags Details
Deom with minimap and dark theme (2.91 MB, image/gif)
2018-06-07 05:47 EDT, Angelo ZERR CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Aelbrecht CLA 2010-07-30 19:00:50 EDT
Build Identifier: 20100218-1602

This is a feature request for the implementation of a Minimap feature, as can be found in the "Sublime" text editor and in a few (non-Eclipse) IDE plugins.

A good explanation, as well as a screenshot can be found here: http://blog.quplo.com/2010/05/5-innovations-in-text-editing-and-ides/

Copy-paste of the description, should the website go down:

"The Sublime text editor puts a column to the left of your text editing environment which displays a Google Maps-like minimap. For editing huge code files, this is a great way to get an overview of the buildup of your code, especially if you need to jump quickly to your class properties, definitions, or just want to get a feel for the structure of your file.

We found that the minimap works best when you’re trying to discipline yourself to keep your files small: large classes in C#, tons of style rules in CSS, and deeply nested HTML become really obvious when the minimap is right there staring at you the whole time."


I think this would be a very powerful addition to Eclipse.

Reproducible: Always
Comment 1 Ludovic Aelbrecht CLA 2010-07-30 19:02:53 EDT
Created attachment 175633 [details]
Screenshot displaying the feature (as implemented in Sublime)
Comment 2 Prakash Rangaraj CLA 2010-07-31 03:19:14 EDT
Platform provides the Outline view for this purpose. What displayed there, however depends on the editor you are using. 

Moving to platform-text for comments
Comment 3 Dani Megert CLA 2010-08-02 03:15:08 EDT
The question is whether this should be limited to text files or whether it might also be useful in general, e.g. for graphics.
Comment 4 Prakash Rangaraj CLA 2010-08-02 03:18:46 EDT
(In reply to comment #3)
> The question is whether this should be limited to text files or whether it
> might also be useful in general, e.g. for graphics.

   If I remember correctly, GEF does supports this kind of functionality in the outline view already.
Comment 5 Dani Megert CLA 2010-08-02 03:24:00 EDT
The problem with the Outline view is that there's only one per editor, unless the specific editor decides to add tabs inside its own outline page.

The question is whether every editor (type) should invent something similar or whether the mini-map (or bird's eye) view comes with the Platform, like the Outline does.
Comment 6 Dani Megert CLA 2010-08-04 03:30:43 EDT
Moving to Platform UI for discussion whether they want to provide this in a generic way. If this is not desired then the bug can be moved back to Text.
Comment 7 Eric Moffatt CLA 2010-08-17 15:24:17 EDT
This could be viewed as a layout issue I think. If we were to put the Outline view *directly* into the same composite as the one hosting the editor it would then appear the same as the 'mini-map' no ?
Comment 8 Eric Moffatt CLA 2010-08-17 15:25:39 EDT
Created attachment 176835 [details]
Mockup of the Outline view 'embedded' in an editor
Comment 9 Dani Megert CLA 2010-08-18 10:44:41 EDT
>This could be viewed as a layout issue I think
Yep, but maybe I'd then like to use that space to put my Java Outline. So, the first questions to answer is: does the mini-map relate to the outline?
Comment 10 Eric Moffatt CLA 2010-08-24 14:57:30 EDT
To me it appears that they're the same concept, must arranged differently. Perhaps just dragging the Outline view to the left of the editor area would help?
Comment 11 Dani Megert CLA 2010-08-25 01:54:41 EDT
>Outline view to the left of the editor area would help?
Mmh, no. It would also need the concept of having multiple pages in the Outline for the same editor part (assuming a mini-map would be general concept in the Platform).
Comment 12 Hitesh CLA 2010-12-10 00:15:58 EST
Eric,
Remy,
I am moving this bug under [EditorMgmt], but if it belongs more to another area such as [DetachedView], please update accordingly. Thanks.
Comment 13 Diogo Santana CLA 2015-07-06 14:01:26 EDT
Any chance to get this implemented?
Comment 14 Dani Megert CLA 2015-07-21 12:28:21 EDT
(In reply to Diogo Santana from comment #13)
> Any chance to get this implemented?

Only if someone contributes a high quality patch.
Comment 15 Mickael Istria CLA 2016-01-04 09:02:46 EST
There is a good plugin providing that on marketplace: https://marketplace.eclipse.org/content/overview-plugin-eclipse
@Sandip: would you be interested in contributing it to Eclipse Platform? Feel free to ask for any guidance!
Comment 16 Sandip Chitale CLA 2016-01-04 21:51:13 EST
Hi Mickael Istria, I would love to contribute the plugin. In fact I had a discussion about it with Lars Vogella about this at EclipseCon 2014 in California.

I would love to get guidance on all the things needed for a successful contribution.
Comment 17 Sandip Chitale CLA 2016-01-04 21:54:46 EST
The source code is available here:

https://github.com/sandipchitale/sandipchitaleseclipseplugins/tree/master/text.overview
Comment 18 Sandip Chitale CLA 2016-01-04 23:23:51 EST
Please see the screen shot in the marketplace entry. My implementation uses a static, fixed width Iviewpart that is by default laid out to the right of editor area. It is shared by and works with all abstracttexteditor sub classes in a generic way.
Comment 19 Mickael Istria CLA 2016-01-05 01:16:16 EST
(In reply to Sandip Chitale from comment #16)
> Hi Mickael Istria, I would love to contribute the plugin.

Great!
 
> I would love to get guidance on all the things needed for a successful
> contribution.

As a 1st iteration, your contribution could take the form of a new bundle inside eclipse.platform.ui:
1. Clone eclipse.platform.ui repository from Gerrit https://git.eclipse.org/r/#/admin/projects/platform/eclipse.platform.ui
2. Add there your plugin, rename the bundle and its packages and other ids (extensions) to something like org.eclipse.ui.text.minimap
3. Add the necessary copyright headers (see other .java files in this repository for examples)
4. Add a line in the bundles/pom.xml to get your bundle built together with platform-ui
5. Git add everything
6. Push to Gerrit: https://wiki.eclipse.org/Gerrit
Once your code is pushed to Gerrit, regular Platform UI committers will be able to have a look at it and provide more specific suggestions, leading to new iterations, until the submission is ready to be merged.

You can find some contributors to help you with that more directly on the #eclipse-dev channel on IRC.
Comment 20 Dani Megert CLA 2016-01-05 05:43:25 EST
(In reply to Mickael Istria from comment #19)
> (In reply to Sandip Chitale from comment #16)
> > Hi Mickael Istria, I would love to contribute the plugin.
> 
> Great!
>  
> > I would love to get guidance on all the things needed for a successful
> > contribution.
> 
> As a 1st iteration, your contribution could take the form of a new bundle
> inside eclipse.platform.ui:

Yes, if the mini map is not for textual editors only. Otherwise the correct place is platform.text. Also, it depends whether this plug-in would work (i.e. provide the mini map) for for all textual editors or whether it has extensions that are expected to be implemented by clients.

I did not look at the code, but a better solution might be to incorporate it into  one of the existing text plug-ins.
Comment 21 Sandip Chitale CLA 2016-01-05 07:28:35 EST
It is for text editors only and it does not expect any extension.

I will start with platform.text and see how it goes.
Comment 22 Dani Megert CLA 2016-01-05 07:36:44 EST
(In reply to Sandip Chitale from comment #21)
> It is for text editors only and it does not expect any extension.
> 
> I will start with platform.text and see how it goes.

If it's for AbstractTextEditor then the 'org.eclipse.ui.workbench.texteditor' would be where I'd start.
Comment 23 Sandip Chitale CLA 2016-01-05 21:32:52 EST
Actually it works at the org.eclipse.swt.custom.StyledText level. If interested see the implementation of the view here:

https://github.com/sandipchitale/sandipchitaleseclipseplugins/blob/master/text.overview/src/text/overview/views/OverviewView.java

and has dependencies on:

Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.jface.text

based on that I guess it belongs in platform.text? (Pardon my ingnorance of this).
Comment 24 Dani Megert CLA 2016-01-06 03:59:03 EST
(In reply to Sandip Chitale from comment #23)
> Actually it works at the org.eclipse.swt.custom.StyledText level. If
> interested see the implementation of the view here:
> 
> https://github.com/sandipchitale/sandipchitaleseclipseplugins/blob/master/text.overview/src/text/overview/views/OverviewView.java
> 
> 
> and has dependencies on:
> 
> Require-Bundle: org.eclipse.ui,
>  org.eclipse.core.runtime,
>  org.eclipse.jface.text
> 
> based on that I guess it belongs in platform.text? 

Yes, and there most likely into the 'org.eclipse.ui.workbench.texteditor' plug-in.


> (Pardon my ingnorance of this).

np.


Before starting to contribute you will have to sign the CLA. See https://wiki.eclipse.org/CLA for details.
Comment 25 Sandip Chitale CLA 2016-01-06 07:22:23 EST
Thanks.

I will sign the CLA.

Are there instructions in one place somewhere on how to set up the development environment.

I did clone the git repo for platform.text and imported the projects. However, then started getting parent pom errors, so had to clone some other repos etc.

Also getting a lot of errors - m2e complaining about lifecycle mapping and so on.

Any help this is welcome.

I use to develop with Eclipse code base before but have not done so lately.
Comment 26 Dani Megert CLA 2016-01-06 08:08:28 EST
(In reply to Sandip Chitale from comment #25)
> Thanks.
> 
> I will sign the CLA.
> 
> Are there instructions in one place somewhere on how to set up the
> development environment.

See https://wiki.eclipse.org/JDT_UI/How_to_Contribute which explains it for JDT UI, but it is similar for Platform Text.

Cloning Platform Text into a new workspace and importing the plug-in mentioned before should be the only thing you need fetch.


> Also getting a lot of errors - m2e complaining about lifecycle mapping and
> so on.

We don't use m2e, so, can't help you with this.
Comment 27 Mickael Istria CLA 2016-01-06 08:56:16 EST
(In reply to Sandip Chitale from comment #25)
> Also getting a lot of errors - m2e complaining about lifecycle mapping and
> so on.

You may be missing the m2e/tycho connector: Got to Preferences > Maven > Discovery, click Open Catalog and install the Tycho connector.
However, as Dani said, you can also ignore m2e if you plan to add your code to an existing plugin.
Comment 28 Sandip Chitale CLA 2016-01-06 21:23:11 EST
For some reason I am not finding the Tycho connector via discovery. Especially for additional goals that Eclipse build seem to be using.

Yes...if I add my view into an existing Eclipse plugin(s) then I just need to be able to build those locally. I will try to follow the link Dani suggested with an example of JDT UI. Presumably it maps similarly for platform.text as well.
Comment 29 Mickael Istria CLA 2016-01-18 08:34:23 EST
Hi Sandip, any progress on that topic? Is there anything we can do to help you?
Comment 30 Sandip Chitale CLA 2016-01-20 09:21:09 EST
Hi Mickael, I have made most of the changes. If interested you can see them in my temp Github repo here:

https://github.com/sandipchitale/eclipse.platform.text


I had a family emergency and hence the delay in setting up the Gerit review. I will get to it by this weekend.
Comment 31 Mickael Istria CLA 2016-03-21 08:25:55 EDT
(In reply to Sandip Chitale from comment #30)
> Hi Mickael, I have made most of the changes. If interested you can see them
> in my temp Github repo here:
> 
> https://github.com/sandipchitale/eclipse.platform.text

Nice. Could you turn those into a Gerrit patch? This is the usual process to contribute to Eclipse Platform: https://wiki.eclipse.org/Platform_UI/How_to_Contribute
Comment 32 Mickael Istria CLA 2017-04-25 03:43:33 EDT
Hi Sandip,
What's the status of your contribution? Are you planning to submit the Gerrit patch soon? Do you need assistance with that?
Comment 33 Angelo ZERR CLA 2017-09-07 07:51:11 EDT
Hi Sandip,

Do you think, there is any chance to have some contribution? Minmap feature is a feature which misses inside Eclipse IDE although other IDE provides already that.

Hope you will find time to contribute to Eclipse IDE.

Regard's Angelo
Comment 34 Angelo ZERR CLA 2018-05-31 05:24:53 EDT
Hi guys,

After studying the code of https://github.com/sandipchitale/sandipchitaleseclipseplugins/blob/master/text.overview/src/text/overview/views/OverviewView.java I have noticed that a new StyledText is used to render the MiniMap. IMHO I think it's a bad idea to do that because for large file I think we can have trouble. An another MiniMap plugin have this problem https://github.com/apauzies/eclipse-minimap-view/issues/4

The reason about this performance problem is because of TextLayout using. StyledText maintains a pool of TextLayout for several lines and dispose it if it needs to render other part of lines. In a editor, there is no problem because we don't render the full lines, but in MiniMap context, we need to render the all lines. I think to have a very good performance, we need to use one TextLayout which draw the all lines.

To do that we need to create a FastStyledText which extends Canvas and use the content, styles of Styledtext of the editor. The idea is to render FastStyledText with the content/styles of StyledText by looping each lines like StyledText#handlePaint does by using StyledTextRenderer.

I have started a POC with that, if you are interested (and once it will work), I could create a gerrit patch if you wish.

@Mickael what do you think about that?
Comment 35 Mickael Istria CLA 2018-05-31 05:28:39 EDT
(In reply to Angelo ZERR from comment #34)
> I have started a POC with that, if you are interested (and once it will
> work), I could create a gerrit patch if you wish.
> @Mickael what do you think about that?

We'd welcome a good patch for it.
Comment 36 Angelo ZERR CLA 2018-05-31 05:42:09 EDT
I tell me if this MinimapView should be hosted more in Platform UI (org.eclipse.ui.views) like PropertySheet, no?
Comment 37 Mickael Istria CLA 2018-05-31 05:44:51 EDT
(In reply to Angelo ZERR from comment #36)
> I tell me if this MinimapView should be hosted more in Platform UI
> (org.eclipse.ui.views) like PropertySheet, no?

If the view is specific to text, it'd be better to try to put it in eclipse.platform.text.
Comment 38 Angelo ZERR CLA 2018-05-31 05:48:27 EDT
> If the view is specific to text, it'd be better to try to put it in eclipse.platform.text.

I agree with you, but imagine that you wish in the future extends the Minimap (to render graphics editor for instance) view like PropertySheet does? In this case Platform UI is better, no?
Comment 39 Mickael Istria CLA 2018-05-31 05:50:17 EDT
(In reply to Angelo ZERR from comment #38)
> > If the view is specific to text, it'd be better to try to put it in eclipse.platform.text.
> 
> I agree with you, but imagine that you wish in the future extends the
> Minimap (to render graphics editor for instance) view like PropertySheet
> does? In this case Platform UI is better, no?

One step after the other. We'll discuss that later, and IIRC, GEF or GMF alrady provides a similar feature.
Comment 40 Dani Megert CLA 2018-05-31 05:53:43 EDT
(In reply to Mickael Istria from comment #39)
> (In reply to Angelo ZERR from comment #38)
> > > If the view is specific to text, it'd be better to try to put it in eclipse.platform.text.
> > 
> > I agree with you, but imagine that you wish in the future extends the
> > Minimap (to render graphics editor for instance) view like PropertySheet
> > does? In this case Platform UI is better, no?
> 
> One step after the other. We'll discuss that later, and IIRC, GEF or GMF
> alrady provides a similar feature.

For me it depends what your Gerrit change provides. If it provides a generic framework that does not depend on Text, then that part should be in Platform UI and maybe an extension for textual editors in Platform Text. But if your change only targets textual editors then I agree with Mickael.
Comment 41 Angelo ZERR CLA 2018-06-01 06:48:08 EDT
>  But if your change only targets textual editors then I agree with Mickael.

Ok let's go for Platform Text. My idea is to host minimap code in the org.eclipse.ui.internal.views.minimap package. Are you OK?

After studying several existing Eclipse Minmap project and experimenting several solution to manage Minimap. The all Minimap that I have seen display the editor content when editor is opened, but doesn't manage the case when editor content changed.

Here my technical conclusion:

1) uses Styledtext instead of Canvas

I though that using Canvas and redraw lines with one TextLayout was fast, but it's not really true. This idea comes from https://github.com/jeeeyul/pde-tools/blob/master/net.jeeeyul.pdetools/src/net/jeeeyul/pdetools/crazyoutline/CrazyCanvas.java I have tested this plugin but with long file, the performance are bad because CrazyCanvas redraw the full content of StyledText and doesn't take care of paint event (y and height) like StyledText does. My test was done by editing big file StyledText.java. The performance with this big file is very good with https://github.com/sandipchitale/sandipchitaleseclipseplugins/blob/master/text.overview/src/text/overview/views/OverviewView.java

2) Use PageBookView instead of ViewPart

The MinimapView must use PageBookView like Outline does. the OverviewView plugin uses ViewPart and there is one StyledText instance used for the whole editor. With PageBookView, we can have an instenace of StyledText per editor. So with that, the StyledText from PageBookView (for Minimap) can be synchronized easily with StyledText from the editor (I mean for text and styles). OverviewView plugin is not able to refresh the Minimap when text changed (The Minimap becomes blank as soon as you type text content, but perhaps I miss something?)

Having a Styledtext instance per editor is easy to synchronize (just with a simple document changed listener for instance)

3) Styles synchronization

At this step we have text in the Minimap with scale. But we need to colorize it and takes care of styles changed. It seems that it's not possible to track the styles changed (when StyledText#setStyles for instance is called). IMHO I think StyledText should provide a new event StyledTextStylesEvent when styles changed. @Dani, @Mickael whet do you think about that? For the moment I have implemented this feature by using presentation listener and it works good with Java Editor, XML Editor which uses presentation listener. Perhaps in the first step we can support only those kinds of editor?

Now I would like to speak about my contribution. My idea is to create several gerrit patchs to facilitate the review:

 * initialize MinimapView which is filled with only text. The minimap will able to be refreshed when text changed.
 * colorize the minimap with styles by using presentation listener.
 * draw the selection backround area in the minimap of the visibles lines of text viewer + manage scroll of this area (to synchronize it with editor scroll).

Are you OK with that? If yes, must I create a bugzilla per issue, or must I use just this bugzilla issue?
Comment 42 Eclipse Genie CLA 2018-06-04 12:51:10 EDT
New Gerrit change created: https://git.eclipse.org/r/123936
Comment 43 Angelo ZERR CLA 2018-06-04 13:14:30 EDT
Created attachment 274323 [details]
Minimap (gerrit patch) demo

@Mickael suggested me to create a big gerrit patch with my whole work with Minimap. Please review my gerrit patch https://git.eclipse.org/r/123936

This gerrit patch display scaled Styledtext with styles and draw view port in the minimap. It support multi part editor and even styles wich defines font (like Markdown).

Please see attached demo.

Ant feedback are welcome, thanks!
Comment 44 Lars Vogel CLA 2018-06-05 06:00:58 EDT
I think the default font in the preview is too small. I cannot identify anything.


IMHO Minimap should react to the font setting of the user for the text font size. If I increase/ decrease the font size with Ctrl+ or Ctrl- I expect minimap to react to this setting. 

I suggest to add a preference for the font size in minimap, I think it should be defined in relation to the text font. 

Background is gray for the unfocused view  on Linux which makes it even harder for me to see something.

Screenshot to follow.
Comment 45 Lars Vogel CLA 2018-06-05 06:01:57 EDT
Created attachment 274331 [details]
Screenshot - Minimap on Linux
Comment 46 Mickael Istria CLA 2018-06-05 06:07:31 EDT
(In reply to Lars Vogel from comment #44)
> I think the default font in the preview is too small. I cannot identify
> anything.

That's how most minimaps work ;) It's not meant to read code.

> IMHO Minimap should react to the font setting of the user for the text font
> size. If I increase/ decrease the font size with Ctrl+ or Ctrl- I expect
> minimap to react to this setting. 

I disagree with that as I believe the goal of the minimap is not to be readable but more to give a visual hint of the position in the file and allow some recognition using the overall shape of the code blocks. It's not intended to read code.
IMO the minimap should take the biggest size that prevents it from requiring a scroll. Minimap requiring scroll would be unusable.
Minimap allowing user configuration would be useless disturbance and doesn't fit in the goal of the minimap.
Comment 47 Mickael Istria CLA 2018-06-05 06:20:05 EDT
@Angelo: thanks for the patch.
How does it integrate with Word-wrap and code minings?
Comment 48 Lars Vogel CLA 2018-06-05 06:22:47 EDT
(In reply to Mickael Istria from comment #46)
> (In reply to Lars Vogel from comment #44)
> > I think the default font in the preview is too small. I cannot identify
> > anything.
> 
> That's how most minimaps work ;) It's not meant to read code.

I'm using minimaps in other editors like Sublime and Code and at least I'm able to identify some structure. The current minimap implementation does not give me any information, as it is too small and uses a wrong background color so that it does not provde any information to me.

And I'm a big fan of minimaps in other editors.
Comment 49 Lars Vogel CLA 2018-06-05 06:44:25 EDT
(In reply to Lars Vogel from comment #48)
> I'm using minimaps in other editors like Sublime and Code and at least I'm
> able to identify some structure. 

Just tested: Code adjusts the minimap font size based on the text font, at least it seems to jump to a larger / small font at certain text size points.
Comment 50 Mickael Istria CLA 2018-06-05 07:22:23 EDT
(In reply to Lars Vogel from comment #49)
> Just tested: Code adjusts the minimap font size based on the text font, at
> least it seems to jump to a larger / small font at certain text size points.

Do you see your whole document all the time?
Comment 51 Angelo ZERR CLA 2018-06-05 07:59:57 EDT
> @Angelo: thanks for the patch.

You are welcome!

> How does it integrate with Word-wrap and code minings?

Word wrap should work but code minings is bugged (it takes some place but without draw of mining, I think we should ignore GlyphMetrics created by minings, but perhaps we could do that in an another gerrit patch?)

> @Mickael, @Lars I'm planned to do a new gerrit patch to improve the draw of highlighted viewport. My main goal is to provide a first patch for a minimap which works well. After that we could improve it like with @Lars suggestion (size of font, etc).

So please wait my gnew changed of gerrit patch and review it to merge it to master if you like it. Thanks!
Comment 52 Angelo ZERR CLA 2018-06-07 05:47:58 EDT
Created attachment 274364 [details]
Deom with minimap and dark theme

@Lars, please retry my new gerrit patch https://git.eclipse.org/r/123936

This gerrit patch improves a lot performance and draw of client area in the minimap. Now I don't use gray color but selection background color with antialias (like block selection). I have fixed too bug when you scroll the client area in teh minimap to avoid drawing selection.
Comment 53 Mickael Istria CLA 2018-06-07 06:07:23 EDT
As we're likely to see a big popularity with code minings in a near future, I think it wouldn't be wise to ship a minimap until it works fine with code minings.
Comment 54 Lars Vogel CLA 2018-06-07 06:22:23 EDT
(In reply to Mickael Istria from comment #53)
> As we're likely to see a big popularity with code minings in a near future,
> I think it wouldn't be wise to ship a minimap until it works fine with code
> minings.

For the first minimal viable solution, I think that code mininings should get ignored in the minimap.
Comment 55 Angelo ZERR CLA 2018-06-07 06:33:03 EDT
> As we're likely to see a big popularity with code minings in a near future, I think it wouldn't be wise to ship a minimap until it works fine with code minings.

Yes sure. IMHO I think code mining draw should be ignored in minimap (for performance reason and more I think it's very usable as it is scaled). For that, we need to ignore GlyphMetrics created by code mining. One idea to do that is to mark StyleRange by using StyleRange.data = "codemining" and minimap could ignore the GlyphMetrics of the the style. It's just an idea...

> For the first minimal viable solution, I think that code mininings should get ignored in the minimap.

Yes please! Please create a new issue for that.
Comment 56 Angelo ZERR CLA 2018-06-15 05:32:22 EDT
Guys please review my new gerrit patch https://git.eclipse.org/r/123936. Except for codemining case, this gerrit patch provide a "mature" minimap in a view.

This gerrit patch should fixes some bugs and this https://bugs.eclipse.org/bugs/show_bug.cgi?id=535735 too
Comment 57 Lars Vogel CLA 2018-06-15 05:42:10 EDT
I think Wim questioned the "Minimap" name. If I search the Internet "Minimap" seems to be the correct term for this feature.  Alternatively "Code preview" comes to mind but if minimap is established we should use that. 

@Angelo WDYT?
Comment 58 Angelo ZERR CLA 2018-06-15 05:50:42 EDT
All Editor text like VSCode, Atom, Sublime etc uses this "minimap" name, so IMHO I think we should keep "Minimap."
Comment 59 Wim Jongman CLA 2018-06-15 07:01:44 EDT
(In reply to Angelo ZERR from comment #58)
> All Editor text like VSCode, Atom, Sublime etc uses this "minimap" name, so
> IMHO I think we should keep "Minimap."

I agree. Sorry for the noise.
Comment 60 Angelo ZERR CLA 2018-06-18 06:59:09 EDT
Please review my last gerrit patch https://git.eclipse.org/r/123936 which ignores GlyphMetrics which id generally created by code mining.
Comment 61 Angelo ZERR CLA 2018-06-20 10:35:46 EDT
@Lars, @Karstem, @Mickael, I would like just to know if you think you will have time to review my minimap gerrit patch. My fear is that you are very busy and review will take long time. I would like to have more people feedbacks and I tell me more and more if I must create a github project with my minimap work. I don't want to have disturb with you and sorry with my impatience.
Comment 62 Lars Vogel CLA 2018-06-20 11:07:03 EDT
I will review tomorrow, sorry for my delay
Comment 63 Angelo ZERR CLA 2018-06-20 11:08:56 EDT
> I will review tomorrow

Very cool!

> sorry for my delay

No pb Lars, I wanted just to know the review status.
Comment 64 Angelo ZERR CLA 2018-06-22 01:23:40 EDT
@Lars I have try to fix all comments that you have told me. I have just one question about version @since. I'm using:

----------------------
@since 3.12
----------------------

But not sure for that, because MANIFEST.MF uses "3.11.100.qualifier". Please tell me which version I must use. Thanks!
Comment 65 Lars Vogel CLA 2018-06-22 02:22:10 EDT
(In reply to Angelo ZERR from comment #64)
> @Lars I have try to fix all comments that you have told me. I have just one
> question about version @since. I'm using:
> 
> ----------------------
> @since 3.12
> ----------------------
> 
> But not sure for that, because MANIFEST.MF uses "3.11.100.qualifier". Please
> tell me which version I must use. Thanks!

IIRC all is internal API? In this case no since tags are necessary
Comment 66 Angelo ZERR CLA 2018-06-22 02:39:17 EDT
> IIRC all is internal API? In this case no since tags are necessary

Thanks @Lars for your clarification. I have removed this since version in my last gerrit patch.
Comment 68 Lars Vogel CLA 2018-06-22 03:01:50 EDT
Thanks a lot Angelo. Can you please add an entry to our N&N for 4.9? We also need a better icon for the view, I will open a bug for that.
Comment 69 Angelo ZERR CLA 2018-06-22 03:31:33 EDT
*** Bug 535450 has been marked as a duplicate of this bug. ***
Comment 70 Till Brychcy CLA 2018-06-22 04:21:38 EDT
It's cool, but at least on the Mac, scrolling the editor is very slow if the minimap view is visible. Is there already a bug for performance improvements?
Comment 71 Lars Vogel CLA 2018-06-22 04:23:06 EDT
(In reply to Till Brychcy from comment #70)
> It's cool, but at least on the Mac, scrolling the editor is very slow if the
> minimap view is visible. Is there already a bug for performance improvements?

I think this is the same as Bug 366471.
Comment 72 Till Brychcy CLA 2018-06-22 04:50:42 EDT
(In reply to Lars Vogel from comment #71)
> (In reply to Till Brychcy from comment #70)
> > It's cool, but at least on the Mac, scrolling the editor is very slow if the
> > minimap view is visible. Is there already a bug for performance improvements?
> 
> I think this is the same as Bug 366471.

Sounds related, but I doubt that that will be improved to the point where the current minimap implementation will be fast enough.
I think of things like:
- Use an offscreen bitmap for caching.
- Update the Minimap asynchronously
Comment 73 Lars Vogel CLA 2018-06-22 04:55:57 EDT
(In reply to Till Brychcy from comment #72)
> Sounds related, but I doubt that that will be improved to the point where
> the current minimap implementation will be fast enough.
> I think of things like:
> - Use an offscreen bitmap for caching.
> - Update the Minimap asynchronously

Great ideas, could you please open a new bug for these suggestions?
Comment 74 Angelo ZERR CLA 2018-06-22 05:00:31 EDT
> I think of things like:
> - Use an offscreen bitmap for caching.
> - Update the Minimap asynchronously

Your strategy changes the whole code of minimap. Today minimap uses a StyledText which is synchronized with StyledText from the editor and update the styles by scaling the font.

It seems that for Windows OS and Linux OS, performance are very good without using some job or creating a bitmap but not for MacOS. I find it's shame to change this code just for one OS without fixing Bug 366471 before. IMHO this bug should be fixed at first to see if we must rewrite the Minimap code with your idea.
Comment 75 Till Brychcy CLA 2018-06-23 06:19:21 EDT
I've created bug 536206 for the issue of mini-map performance on Mac OS.
Comment 76 Lars Vogel CLA 2018-06-25 05:59:40 EDT
Angelo, please provide Gerrit for N&N.
Comment 77 Angelo ZERR CLA 2018-06-26 06:02:43 EDT
> Angelo, please provide Gerrit for N&N.

I will try to do that this week.
Comment 78 Matthias Becker CLA 2018-06-27 07:03:45 EDT
when I open the View the first time it is opened below editor are.
Wouldn't it make more sense to open in e.g. in the same location where the outline is?

Another question: How do we tell users that we have this new view?
Comment 79 Eclipse Genie CLA 2018-06-28 03:51:26 EDT
New Gerrit change created: https://git.eclipse.org/r/125143
Comment 80 Angelo ZERR CLA 2018-06-28 03:53:10 EDT
> when I open the View the first time it is opened below editor are.
Wouldn't it make more sense to open in e.g. in the same location where the outline is? Another question: How do we tell users that we have this new view?

Please create a new bug for your new requirement. Goal of this issue was to provide a basic Minimap. If Minimap must be improved please create another bug. Thanks!
Comment 81 Angelo ZERR CLA 2018-06-28 03:53:57 EDT
> Angelo, please provide Gerrit for N&N.

@Lars, please review my N&N at https://git.eclipse.org/r/125143
Comment 82 Lars Vogel CLA 2018-06-28 04:06:31 EDT
(In reply to Angelo ZERR from comment #80)
> Please create a new bug for your new requirement. Goal of this issue was to
> provide a basic Minimap. If Minimap must be improved please create another
> bug. Thanks!

Bug 536393
Comment 84 Sebastian Ratz CLA 2018-07-23 13:19:07 EDT
This change can cause a ClassCastException

https://git.eclipse.org/r/plugins/gitiles/platform/eclipse.platform.text/+/refs/changes/36/123936/16/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/views/minimap/MinimapPage.java#33

It is not guaranteed that the ITextOperationTarget is always also the ITextViewer and the hard typecast is unsafe.

Shouldn't the handling instead check if the given editor inherits from AbstractTextEditor and then get the ISourceViewer from that via 
AbstractTextEditor.getSourceViewer()?
Comment 85 Matthias Becker CLA 2018-07-24 05:19:40 EDT
As there are issues (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=321410#c84) I reopen this bug.
Comment 86 Matthias Becker CLA 2018-07-24 05:20:03 EDT
see above
Comment 87 Angelo ZERR CLA 2018-07-24 05:33:13 EDT
> It is not guaranteed that the ITextOperationTarget is always also the ITextViewer and the hard typecast is unsafe.

In theory, I agree with you, but have you a usecase?

> Shouldn't the handling instead check if the given editor inherits from >AbstractTextEditor and then get the ISourceViewer from that via 
>AbstractTextEditor.getSourceViewer()?

AbstractTextEditor.getSourceViewer() is protected, and using reflection is not very clean. So we cannot use it I think.

in other words, using ITextOperationTarget is the only solution that I know. Perhaps we should keep this mean to retrieve ISourceViewer by checking the instanceof ISourceViewer and not enable minimap in the case of ITextOperationTarget  is not an instance of ISourceViewer .
Comment 88 Till Brychcy CLA 2018-07-24 06:08:00 EDT
(In reply to Angelo ZERR from comment #87)
> in other words, using ITextOperationTarget is the only solution that I know.
> Perhaps we should keep this mean to retrieve ISourceViewer by checking the
> instanceof ISourceViewer and not enable minimap in the case of
> ITextOperationTarget  is not an instance of ISourceViewer .

Actually it looks like you only need ITextViewer, not ISourceViewer.

What about implementing ITextViewer as target for org.eclipse.ui.texteditor.AbstractTextEditor.getAdapter(Class<T>), so you could write:
fEditorViewer = (ITextViewer) textEditor.getAdapter(ITextViewer.class)

Of course you'll have to handle the case where this returns null.
Comment 89 Sebastian Ratz CLA 2018-07-24 06:23:44 EDT
(In reply to Angelo ZERR from comment #87)
> > It is not guaranteed that the ITextOperationTarget is always also the ITextViewer and the hard typecast is unsafe.
> 
> In theory, I agree with you, but have you a usecase?

In our ABAP development tools (ADT), editor.getAdapter(ITextOperationTarget.class) does not return the ISourceViewer implcitly.

In general, we cannot assume that every implementation of ITextEditor subclasses AbstractTextEditor and even has an ISourceViewer under the hood.


> > Shouldn't the handling instead check if the given editor inherits from >AbstractTextEditor and then get the ISourceViewer from that via 
> >AbstractTextEditor.getSourceViewer()?
> 
> AbstractTextEditor.getSourceViewer() is protected, and using reflection is
> not very clean. So we cannot use it I think.

Good point. A solution would be to add an internal interface IAbstractTextViewer so that it can be accessed for this use case.

> in other words, using ITextOperationTarget is the only solution that I know.

It is indeed a nice solution that will likely be able to work with many existing implementations. But as it feels like a hack which works just by chance.

> Perhaps we should keep this mean to retrieve ISourceViewer by checking the
> instanceof ISourceViewer and not enable minimap in the case of
> ITextOperationTarget  is not an instance of ISourceViewer .

Yes, I do like like the solution, but IMHO it should be a fallback to an more official (and semantically more logial) API (see below).

(In reply to Till Brychcy from comment #88)
> Actually it looks like you only need ITextViewer, not ISourceViewer.
> 
> What about implementing ITextViewer as target for
> org.eclipse.ui.texteditor.AbstractTextEditor.getAdapter(Class<T>), so you
> could write:
> fEditorViewer = (ITextViewer) textEditor.getAdapter(ITextViewer.class)
> 
> Of course you'll have to handle the case where this returns null.

This sounds like the proper way to do it. With the fallback solution it could look like this:

fEditorViewer = textEditor.getAdapter(ITextViewer.class);
if (fEditorViewer == null) {
  // try to get the ITextViewer by alternative means:
  // Try with getting the ITextOperationTarget. It is likely that the instance implementing
  // ITextOperationTarget is also the same instance implementing ITextViewer.
  ITextOperationTarget textOperationTarget = textEditor.getAdapter(ITextOperationTarget.class);
  if (textOperationTarget instanceof ITextViewer) {
    fEditorViewer = (ITextViewer) textOperationTarget;
  }
}
Comment 90 Matthias Becker CLA 2018-07-24 07:20:47 EDT
(In reply to Sebastian Ratz from comment #89)
> This sounds like the proper way to do it. With the fallback solution it
> could look like this:
> 
> fEditorViewer = textEditor.getAdapter(ITextViewer.class);
> if (fEditorViewer == null) {
>   // try to get the ITextViewer by alternative means:
>   // Try with getting the ITextOperationTarget. It is likely that the
> instance implementing
>   // ITextOperationTarget is also the same instance implementing ITextViewer.
>   ITextOperationTarget textOperationTarget =
> textEditor.getAdapter(ITextOperationTarget.class);
>   if (textOperationTarget instanceof ITextViewer) {
>     fEditorViewer = (ITextViewer) textOperationTarget;
>   }
> }
That sounds reasonable for me.
Comment 91 Angelo ZERR CLA 2018-07-24 07:55:17 EDT
> What about implementing ITextViewer as target for org.eclipse.ui.texteditor.AbstractTextEditor.getAdapter(Class<T>), so you could write:
fEditorViewer = (ITextViewer) textEditor.getAdapter(ITextViewer.class)

@Till is there any change to provide a gerrit patch?
Comment 92 Till Brychcy CLA 2018-07-24 07:59:15 EDT
(In reply to Angelo ZERR from comment #91)
> > What about implementing ITextViewer as target for org.eclipse.ui.texteditor.AbstractTextEditor.getAdapter(Class<T>), so you could write:
> fEditorViewer = (ITextViewer) textEditor.getAdapter(ITextViewer.class)
> 
> @Till is there any change to provide a gerrit patch?

Extending AbstractTextEditor.getAdapter should be trivial.
I can provide gerrit this evening if you want.
Comment 93 Eclipse Genie CLA 2018-07-24 15:07:29 EDT
New Gerrit change created: https://git.eclipse.org/r/126575
Comment 94 Till Brychcy CLA 2018-07-24 15:13:49 EDT
(In reply to Eclipse Genie from comment #93)
> New Gerrit change created: https://git.eclipse.org/r/126575

Note: I've tested the "null"-case by temporarliy altering createMinimap to return null based on the editor title for a plain Example.java-file and a pom.xml (for testing  MultiPageMinimapPage)
Comment 95 Till Brychcy CLA 2018-07-25 04:41:17 EDT
(In reply to Till Brychcy from comment #94)
> (In reply to Eclipse Genie from comment #93)
> > New Gerrit change created: https://git.eclipse.org/r/126575
> 
> Note: I've tested the "null"-case by temporarliy altering createMinimap to
> return null based on the editor title for a plain Example.java-file and a
> pom.xml (for testing  MultiPageMinimapPage)

Angelo has also tested the change. 
Can a platform committer please commit this.
Comment 96 Matthias Becker CLA 2018-07-25 05:16:33 EDT
(In reply to Till Brychcy from comment #95)
> (In reply to Till Brychcy from comment #94)
> > (In reply to Eclipse Genie from comment #93)
> > > New Gerrit change created: https://git.eclipse.org/r/126575
> > 
> > Note: I've tested the "null"-case by temporarliy altering createMinimap to
> > return null based on the editor title for a plain Example.java-file and a
> > pom.xml (for testing  MultiPageMinimapPage)
> 
> Angelo has also tested the change. 
> Can a platform committer please commit this.

I can do.
Would be good to have automated tests for that code. Can you provide some?
Comment 97 Till Brychcy CLA 2018-07-25 05:27:46 EDT
(In reply to Matthias Becker from comment #96)
> I can do.
> Would be good to have automated tests for that code. Can you provide some?

I agree tests would be nice but I haven't seen an existing test for the existing code that just needs modification, so that would currently be too much work for me.
So sorry, no.
Comment 99 Matthias Becker CLA 2018-07-25 05:37:14 EDT
(In reply to Till Brychcy from comment #97)
> (In reply to Matthias Becker from comment #96)
> > I can do.
> > Would be good to have automated tests for that code. Can you provide some?
> 
> I agree tests would be nice but I haven't seen an existing test for the
> existing code that just needs modification, so that would currently be too
> much work for me.
> So sorry, no.

Okay I understand this.
So this would then be a task for Angelo who has contributes this feature.
@Angelo: Can you please provide automated tests for the minimap feature in general.
Comment 100 Matthias Becker CLA 2018-07-25 05:38:08 EDT
(In reply to Till Brychcy from comment #95)
> Can a platform committer please commit this.

done. Thank you Till for fixing this on short notice
Comment 101 Angelo ZERR CLA 2018-07-26 02:08:24 EDT
> @Angelo: Can you please provide automated tests for the minimap feature in general.

To be honnest with you, I don't know which test kind I could write it and how I could write it. Minimap looks like Outline, and I have not found Outline tests too.
Comment 102 Matthias Becker CLA 2018-08-02 02:27:24 EDT
(In reply to Angelo ZERR from comment #101)
> To be honnest with you, I don't know which test kind I could write it and
> how I could write it. Minimap looks like Outline, and I have not found
> Outline tests too.

As we now deliver more frequent to our customers we don't have a lot of time in which we as commits can find bugs during our daily use of new eclipse versions. So for me automated tests now are even more important. 
If the outline is a bad example (for having no automated tests) then this should not prevent us to write new tests for new features.

If you like an example: Have a look at https://git.eclipse.org/r/#/c/125791/. There we currently develop a new feature directly along with unit tests. Maybe the tests give you some inspiration.
Comment 103 Angelo ZERR CLA 2018-08-02 03:22:12 EDT
> So for me automated tests now are even more important. 

I totally agree with you!

> If you like an example: Have a look at https://git.eclipse.org/r/#/c/125791/. There we currently develop a new feature directly along with unit tests. Maybe the tests give you some inspiration.

This test is not for UI. So to be honnest with you, it doesn't help me. It's very hard to test UI features. I think to have a good test for minimap we should test the MinimapWidget  bind with a StyledText (a text editor):

 * test MinimapWidget content : when StyledText content of editor changed, MinimapWidget content changed.
 * test MinimapWidget styles : when StyledText styles of editor changed, MinimapWidget styles changed.
 * test draw of square.

I have no idea for the moment how to write that. If someone have some idea, any help are welcome!
Comment 104 Matthias Becker CLA 2018-08-02 03:58:41 EDT
(In reply to Angelo ZERR from comment #103)
> This test is not for UI. So to be honnest with you, it doesn't help me. It's
> very hard to test UI features. I think to have a good test for minimap we
> should test the MinimapWidget  bind with a StyledText (a text editor):

But isn't there stuff that can be tested without UI?

> 
> I have no idea for the moment how to write that. If someone have some idea,
> any help are welcome!

Can somebody help Angelo with input how to write a good UI testP
Comment 105 Eclipse Genie CLA 2018-08-02 05:33:38 EDT
New Gerrit change created: https://git.eclipse.org/r/126948
Comment 106 Angelo ZERR CLA 2018-08-02 05:53:43 EDT
> Can somebody help Angelo with input how to write a good UI testP

Forget my comments, tests was easy to write for testing "MinimapWidget content/styles. Please review my gerrit patch https://git.eclipse.org/r/#/c/126948/

> I agree tests would be nice but I haven't seen an existing test for the existing code that just needs modification, so that would currently be too much work for me.
So sorry, no.

Done with MinimapPageTest in my gerrit patch https://git.eclipse.org/r/#/c/126948/

On the other side, testing draw of square (which seems bugged https://bugs.eclipse.org/bugs/show_bug.cgi?id=536207) is more difficult. If you like my tests, please merge it and I think this issue can be closed, because it exists https://bugs.eclipse.org/bugs/show_bug.cgi?id=536207 to fix the bug with square)
Comment 107 Matthias Becker CLA 2018-08-02 07:14:46 EDT
(In reply to Angelo ZERR from comment #106)
> > Can somebody help Angelo with input how to write a good UI testP
> 
> Forget my comments, tests was easy to write for testing "MinimapWidget
> content/styles. Please review my gerrit patch
> https://git.eclipse.org/r/#/c/126948/
> 
> > I agree tests would be nice but I haven't seen an existing test for the existing code that just needs modification, so that would currently be too much work for me.
> So sorry, no.
> 
> Done with MinimapPageTest in my gerrit patch
> https://git.eclipse.org/r/#/c/126948/
> 
> On the other side, testing draw of square (which seems bugged
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=536207) is more difficult. If
> you like my tests, please merge it and I think this issue can be closed,
> because it exists https://bugs.eclipse.org/bugs/show_bug.cgi?id=536207 to
> fix the bug with square)

Just merged your tests. Well done. Thank you.
Comment 109 Eclipse Genie CLA 2018-08-02 10:27:22 EDT
New Gerrit change created: https://git.eclipse.org/r/126976