Author: dmaliarevich
Date: 2012-02-02 09:44:20 -0500 (Thu, 02 Feb 2012)
New Revision: 38395
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-8701 - source scrolling was updated.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02
12:47:39 UTC (rev 38394)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02
14:44:20 UTC (rev 38395)
@@ -363,14 +363,18 @@
sourceScrollSelectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
+ /*
+ * Check that scrolling is reasonable:
+ * when scrollMaxYVisual > 0
+ */
+ int scrollMaxYVisual = windowInternal.getScrollMaxY();
if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
&& !visualScrollEventFlag &&
!selectionManager.isUpdateSelectionEventPerformed()
- && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { //
ignore internal visual scroll event
+ && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE
+ && scrollMaxYVisual > 0) { // ignore internal visual scroll event
sourceScrollEventFlag = true;
int posY = scrollCoordinator.computeVisualPositionFromSource();
- int scrollMaxYVisual = -1;
- scrollMaxYVisual = windowInternal.getScrollMaxY();
if (posY > scrollMaxYVisual) {
posY = scrollMaxYVisual;
}
@@ -1085,6 +1089,7 @@
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
&& !sourceScrollEventFlag &&
!selectionManager.isUpdateSelectionEventPerformed()
&& editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { // ignore
internal event from source
+ System.out.println("vis scroll");
removeSourceScrollListener();
visualScrollEventFlag = true;
int line = scrollCoordinator.computeSourcePositionFromVisual();
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02
12:47:39 UTC (rev 38394)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02
14:44:20 UTC (rev 38395)
@@ -207,16 +207,14 @@
int resultOffset = -1;
StyledText textWidget = itextViewer.getTextWidget();
if (textWidget != null) {
- // lineIndex-1 because calculating of line begins in eclipse from
- // one, but should be form zero
- resultOffset = textWidget.getOffsetAtLine(lineIndex - 1);
+ resultOffset = textWidget.getOffsetAtLine(lineIndex);
// here we get's tabs length
// for more example you can see code
// org.eclipse.ui.texteditor.AbstractTextEditor@getCursorPosition()
// and class $PositionLabelValue
int tabWidth = textWidget.getTabs();
int characterOffset = 0;
- String currentString = textWidget.getLine(lineIndex - 1);
+ String currentString = textWidget.getLine(lineIndex);
int pos = 1;
for (int i = 0; (i < currentString.length())
&& (pos < linePosition); i++) {
@@ -229,7 +227,7 @@
}
}
resultOffset += characterOffset;
- if (textWidget.getLineAtOffset(resultOffset) != (lineIndex - 1)) {
+ if (textWidget.getLineAtOffset(resultOffset) != lineIndex) {
resultOffset = -1;
}
}