summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSteve Jahns2013-10-09 16:38:46 (EDT)
committer admin2013-10-09 16:39:12 (EDT)
commit763de078802b252b1dae190bb7b8e9551867b7da (patch)
treedeb448cf315a0b2759797dfa3e5183e04dcae575
parent803d4116d6483936386690f0d075eaf2a2fe6dac (diff)
downloadorg.eclipse.orion.client-763de078802b252b1dae190bb7b8e9551867b7da.zip
org.eclipse.orion.client-763de078802b252b1dae190bb7b8e9551867b7da.tar.gz
org.eclipse.orion.client-763de078802b252b1dae190bb7b8e9551867b7da.tar.bz2
Bug 418216 - Vi Keybindings - Missing * search --Signed-off-by: Steve Jahns <s.t.jahns@gmail.com>
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/nls/root/messages.js2
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js14
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/vi.js21
3 files changed, 36 insertions, 1 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/nls/root/messages.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/nls/root/messages.js
index c749b91..952198a 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/nls/root/messages.js
@@ -185,6 +185,8 @@ define({
"viC": "Change Text Until Line End", //$NON-NLS-1$ //$NON-NLS-0$
"vip": "Paste After Char or Line", //$NON-NLS-1$ //$NON-NLS-0$
"viP": "Paste Before Char or Line", //$NON-NLS-1$ //$NON-NLS-0$
+ "viStar": "Search Word Under Cursor", //$NON-NLS-1$ //$NON-NLS-0$
+
"replaceAll": "Replacing all...", //$NON-NLS-1$ //$NON-NLS-0$
"replacedMatches": "Replaced ${0} matches", //$NON-NLS-1$ //$NON-NLS-0$
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 2c95432..30a9560 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
@@ -1713,6 +1713,20 @@ define("orion/editor/textView", [ //$NON-NLS-0$
return {x: x, y: y};
},
/**
+ * Returns the next character offset after the given offset and options
+ *
+ * @param {Number} offset the offset to start from
+ * @param {Object} options
+ * { unit: the type of unit to advance to (eg "character", "word", "wordend", "wordWS", "wordendWS"),
+ * count: the number of units to advance (negative to advance backwards) }
+ * @returns {Number} the next character offset
+ */
+ getNextOffset: function(offset, options) {
+ var selection = new Selection(offset, offset, false);
+ this._doMove(options, selection);
+ return selection.getCaret();
+ },
+ /**
* Returns the specified view options.
* <p>
* The returned value is either a <code>orion.editor.TextViewOptions</code> or an option value. An option value is returned when only one string paremeter
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/vi.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/vi.js
index 2fec09f..ce21652 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/vi.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/vi.js
@@ -671,7 +671,8 @@ define("orion/editor/vi", [ //$NON-NLS-0$
bindings.push({actionID: "vi-C", keyBinding: createStroke("C", false, false, false, false, "keypress"), predefined: true}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
bindings.push({actionID: "vi-D", keyBinding: createStroke("D", false, false, false, false, "keypress"), predefined: true}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
-
+ bindings.push({actionID: "vi-*", keyBinding: createStroke("*", false, false, false, false, "keypress"), predefined: true}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+
return bindings;
},
getKeyBindings: function (actionID) {
@@ -855,6 +856,24 @@ define("orion/editor/vi", [ //$NON-NLS-0$
view.setAction("vi-D", function() { //$NON-NLS-0$
return self._invoke("deleteLineEnd"); //$NON-NLS-0$
}, {name: messages.deleteLineEnd});
+
+ view.setAction("vi-*", function() { //$NON-NLS-0$
+ // Get word under caret
+ var view = self.getView();
+ var caret = view.getCaretOffset();
+ var wordStart = view.getNextOffset(caret + 1, {count: -1, unit: "word"}); //$NON-NLS-0$
+ var wordEnd = view.getNextOffset(wordStart, {count: 1, unit: "wordend"}); //$NON-NLS-0$
+ var text = view.getText(wordStart, wordEnd);
+ // Search for the word
+ self._searchFwd = true;
+ var data = {
+ hideAfterFind: true,
+ incremental: false,
+ reverse: false,
+ findString: text
+ };
+ return self._invoke("find", data); //$NON-NLS-0$
+ }, {name: messages.viStar});
// Status Line Mode
// view.setAction("statusLineMode", function() { //$NON-NLS-0$