Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344476

Summary: [client] Navigating via outline behaves strangely
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Susan McCourt <susan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, john.arthorne, simon_kaegi
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2011-05-02 11:38:25 EDT
Orion 0.2 M7

1. Open a .js file in the editor.
2. Click one of the links in the outline view to jump to a line.
3. Scroll away.
4. Now click the same link in the outline view again. Nothing happens.

I expected the editor to take me back to the line.
Comment 1 Boris Bokowski CLA 2011-05-02 23:39:22 EDT
I had a problem with the outline in my demo today - clicking on links in the outline caused the editor buffer to reload (instead of just scrolling to the position). Is the outline working fine for others?
Comment 2 John Arthorne CLA 2011-05-03 09:54:23 EDT
This is different from how browsers seem to handle the same case in simple HTML. For example go here:

http://wiki.eclipse.org/Orion/Server_admin_guide

- Click an entry in the index
- Scroll back to the top, and click the same entry again

-> The browser jumps back down to the anchor, even though the page address has not changed. I suspect we must have an optimization in our code where we short-circuit if the hash has not changed.
Comment 3 John Arthorne CLA 2011-05-03 09:57:22 EDT
(In reply to comment #1)
> I had a problem with the outline in my demo today - clicking on links in the
> outline caused the editor buffer to reload (instead of just scrolling to the
> position). Is the outline working fine for others?

I have not seen that on either FF4 or Chrome 11, on Windows 7. You are seeing this on Mac Safari?
Comment 4 Susan McCourt CLA 2011-05-03 11:57:12 EDT
I've not seen Boris' problem  on win7 FF or Chrome.  Boris, if you are able to reproduce this can you open a new bug?

I can reproduce what Mark observes.  If you select an outliner link that's already selected and then scroll, clicking again won't readjust the viewport.

The code calls editor.showSelection so I suspect any shortcircuiting would be happening inside the editor, but let me step through it to be sure.
Comment 5 Susan McCourt CLA 2011-05-03 12:08:50 EDT
There was an equality check in the hashchanged handler for the editor, which I removed.  But of course the problem is simply that the URL is not changing in this case, so the dojo hash change doesn't even fire.  (the short circuit is either in dojo or even in the browser).

We now have two bugs (the other is bug 335637) where the outliner is not working as we'd like because of our use of real anchor tags.

I think the solution for both of these bugs is to put custom onclick handlers in the outliner anchor tags and use the selection service rather than following real links and relying on hash change.  This would fix both bugs.
Comment 6 Susan McCourt CLA 2011-05-03 13:40:40 EDT
(In reply to comment #5)

> I think the solution for both of these bugs is to put custom onclick handlers
> in the outliner anchor tags and use the selection service rather than following
> real links and relying on hash change.  This would fix both bugs.

Fixed as described.  If an outliner is created and a selection service is not specified, the old behavior of using anchor tag hrefs will continue to be supported.  

But if a selection service is supplied, then we just update the selection service, which means we are just using editor API to navigate the text in the editor and not playing with the hash at all.  I did ensure that if the user ctrl-clicks the link, we still open a new page.  But regular clicks will just navigate the editor without updating the hash.  (Similar to if the user used ctrl-L to goto line, which also does not update the hash).