views:

468

answers:

1

Sometimes when I jump into source code, e.g. from search or when looking up the declaration of something, the Eclipse text editor tries to display nearby long lines by horizontal scrolling. This happens even if the item I jumped to is well within the display without scrolling. I find this rather annoying, so:

Is there a way to disable this? I have searched in vain through all the editor settings.

Specifically, this is about Eclipse CDT, but I suppose the behaviour is the same in JDT.

+1  A: 

This seems to happen in other eclipse editors too (like PDT for PHP)

It could have been related with the ScrolledFormText, but the Plugin Spy tells us a WorkbenchWindow class is concerned, as well as an AbstractDecoratedTextEditor, that is in essence an org.eclipse.ui.texteditor.AbstractTextEditor.

The source of that AbstractTextEditor indicates having:

  • a ScrollLinesAction for vertical scrolling
  • a TextNavigationAction for settings the cursor and potentially triggering horizontal scrolling

I am not sure how to change that behavior, except by contributing somehow to the active editor identifier (for instance, for java, "org.eclipse.jdt.ui.ClassFileEditor"), and modifying that Action.

VonC
For the time being I tracked it back to ITextViewer.revealRange().
starblue
@starblue: Interesting. Did you manage to override its behavior ?
VonC