aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2013-03-13 17:32:55 (EDT)
committerSilenio Quarti2013-03-13 17:36:33 (EDT)
commit250c204734f45a65ec985013752c799d4f78e72e (patch)
tree04467d8e6d415e8a0575231318ad76debee61103
parentda63ce3c9723a892b1e677ecd99ba3025802234a (diff)
downloadorg.eclipse.orion.client-250c204734f45a65ec985013752c799d4f78e72e.zip
org.eclipse.orion.client-250c204734f45a65ec985013752c799d4f78e72e.tar.gz
org.eclipse.orion.client-250c204734f45a65ec985013752c799d4f78e72e.tar.bz2
Bug 403270 - Overview Ruler should select annotation
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js23
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/rulers.js47
2 files changed, 42 insertions, 28 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
index 95e8dc6..dbf06ca 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
@@ -13,7 +13,6 @@
/*jslint maxerr:150 browser:true devel:true laxbreak:true regexp:false*/
define("orion/editor/editor", ['i18n!orion/editor/nls/messages', 'orion/keyBinding', 'orion/editor/eventTarget', 'orion/editor/tooltip', 'orion/editor/annotations', 'orion/util'], function(messages, mKeyBinding, mEventTarget, mTooltip, mAnnotations, util) { //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- var Animation;
var HIGHLIGHT_ERROR_ANNOTATION = "orion.annotation.highlightError"; //$NON-NLS-0$
@@ -608,23 +607,6 @@ define("orion/editor/editor", ['i18n!orion/editor/nls/messages', 'orion/keyBindi
var rulers = this._annotationFactory.createAnnotationRulers(this._annotationModel);
var ruler = this._annotationRuler = rulers.annotationRuler;
if (ruler) {
- ruler.onClick = function(lineIndex, e) {
- if (lineIndex === undefined) { return; }
- if (lineIndex === -1) { return; }
- var view = this.getView();
- var viewModel = view.getModel();
- var annotationModel = this.getAnnotationModel();
- var lineStart = editor.mapOffset(viewModel.getLineStart(lineIndex));
- var lineEnd = editor.mapOffset(viewModel.getLineEnd(lineIndex));
- var annotations = annotationModel.getAnnotations(lineStart, lineEnd);
- while (annotations.hasNext()) {
- var annotation = annotations.next();
- if (!this.isAnnotationTypeVisible(annotation.type)) { continue; }
- var model = editor.getModel();
- editor.onGotoLine(model.getLineAtOffset(lineStart), annotation.start - lineStart, annotation.end - lineStart);
- break;
- }
- };
ruler.onDblClick = addRemoveBookmark;
ruler.setMultiAnnotationOverlay({html: "<div class='annotationHTML overlay'></div>"}); //$NON-NLS-0$
ruler.addAnnotationType(mAnnotations.AnnotationType.ANNOTATION_ERROR);
@@ -636,11 +618,6 @@ define("orion/editor/editor", ['i18n!orion/editor/nls/messages', 'orion/keyBindi
ruler = this._overviewRuler = rulers.overviewRuler;
if (ruler) {
- ruler.onClick = function(lineIndex, e) {
- if (lineIndex === undefined) { return; }
- var offset = textView.getModel().getLineStart(lineIndex);
- editor.moveSelection(editor.mapOffset(offset));
- };
ruler.addAnnotationType(mAnnotations.AnnotationType.ANNOTATION_CURRENT_SEARCH);
ruler.addAnnotationType(mAnnotations.AnnotationType.ANNOTATION_MATCHING_SEARCH);
ruler.addAnnotationType(mAnnotations.AnnotationType.ANNOTATION_ERROR);
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/rulers.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/rulers.js
index a7678d8..2316205 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/rulers.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/rulers.js
@@ -249,6 +249,48 @@ define("orion/editor/rulers", ['i18n!orion/editor/nls/messages', 'orion/editor/a
* @param {DOMEvent} e the click event.
*/
onClick: function(lineIndex, e) {
+ if (lineIndex === undefined) { return; }
+ var view = this._view;
+ var model = view.getModel();
+ var baseModel = model;
+ var start = model.getLineStart(lineIndex);
+ var end = start;
+ var annotationModel = this._annotationModel;
+ if (annotationModel) {
+ var selection = view.getSelection();
+ var offset = Math.max(selection.start, selection.end);
+ end = model.getLineEnd(lineIndex, true);
+ if (start <= offset && offset < model.getLineEnd(lineIndex)) {
+ start = offset + 1;
+ }
+ if (model.getBaseModel) {
+ start = model.mapOffset(start);
+ end = model.mapOffset(end);
+ baseModel = model.getBaseModel();
+ }
+ var annotation, iter = annotationModel.getAnnotations(start, end);
+ while (!annotation && iter.hasNext()) {
+ var a = iter.next();
+ if (!this.isAnnotationTypeVisible(a.type)) { continue; }
+ annotation = a;
+ }
+ if (annotation && baseModel.getLineAtOffset(annotation.start) === baseModel.getLineAtOffset(start)) {
+ start = annotation.start;
+ end = annotation.end;
+ } else {
+ end = start;
+ }
+
+ if (model.getBaseModel) {
+ start = model.mapOffset(start, true);
+ end = model.mapOffset(end, true);
+ }
+ }
+ var tooltip = mTooltip.Tooltip.getTooltip(this._view);
+ if (tooltip) {
+ tooltip.setTarget(null);
+ }
+ this._view.setSelection(end, start, 1/3, function(){});
},
/**
* This event is sent when the user double clicks a line annotation.
@@ -548,11 +590,6 @@ define("orion/editor/rulers", ['i18n!orion/editor/nls/messages', 'orion/editor/a
result = this._mergeStyle(result, this._rulerStyle);
return result;
};
- /** @ignore */
- OverviewRuler.prototype.onClick = function(lineIndex, e) {
- if (lineIndex === undefined) { return; }
- this._view.setTopIndex(lineIndex);
- };
/** @ignore */
OverviewRuler.prototype._getTooltipContents = function(lineIndex, annotations) {
if (annotations.length === 0) {