aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-11-14 10:43:34 (EST)
committerGerrit Code Review @ Eclipse.org2013-11-15 15:21:09 (EST)
commit3375eba48c6892cb31eaaa2b5982f729c155eeed (patch)
tree974572ad1dd1d26afd185600f86e2aaa57f50e7f
parent468084998e2c63e2a3e16f287115a81573782f7a (diff)
downloadorg.eclipse.orion.client-3375eba48c6892cb31eaaa2b5982f729c155eeed.zip
org.eclipse.orion.client-3375eba48c6892cb31eaaa2b5982f729c155eeed.tar.gz
org.eclipse.orion.client-3375eba48c6892cb31eaaa2b5982f729c155eeed.tar.bz2
Bug 421580 - Should expose getLineAtOffset to service providersv20131115-2021refs/changes/90/18390/5
Change-Id: Id514b2ad5eb82f06740bb18dc505ee34bdee3a5e Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js16
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js14
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/editorView.js3
3 files changed, 30 insertions, 3 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 439ca9d..cbab035 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
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
- * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * Copyright (c) 2009, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
@@ -438,7 +438,19 @@ define("orion/editor/editor", [ //$NON-NLS-0$
}
return offset;
},
-
+ /**
+ * @name getLineAtOffset
+ * @description Returns the line number corresponding to the given offset in the source
+ * @function
+ * @public
+ * @memberof orion.editor.Editor
+ * @param {Number} offset The offset into the source
+ * @returns {Number} The line number corresponding to the given offset or <code>-1</code> if out of range
+ * @since 5.0
+ */
+ getLineAtOffset: function(offset) {
+ return this.getModel().getLineAtOffset(this.mapOffset(offset));
+ },
getCaretOffset: function() {
return this.mapOffset(this._textView.getCaretOffset());
},
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
index b737238..e93f148 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
@@ -1791,6 +1791,20 @@ define("orion/editor/textView", [ //$NON-NLS-0$
return offset;
},
/**
+ * @name getLineAtOffset
+ * @description Compute the editor line number for the given offset
+ * @function
+ * @public
+ * @memberof orion.editor.TextView
+ * @param {Number} offset The offset into the editor
+ * @returns {Number} Returns the line number in the editor corresponding to the given offset or <code>-1</code> if the offset is
+ * out of range
+ * @since 5.0
+ */
+ getLineAtOffset: function(offset) {
+ this.getModel().getLineAtOffset(offset);
+ },
+ /**
* Get the view rulers.
*
* @returns {orion.editor.Ruler[]} the view rulers
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/editorView.js b/bundles/org.eclipse.orion.client.ui/web/orion/editorView.js
index b49ee0c..76a1b8e 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/editorView.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/editorView.js
@@ -337,7 +337,8 @@ define([
var contextImpl = {};
[ "getCaretOffset", "setCaretOffset",
"getSelection", "setSelection",
- "getText", "setText"
+ "getText", "setText",
+ "getLineAtOffset"
].forEach(function(method) {
contextImpl[method] = editor[method].bind(editor);
});