diff options
author | Andrew Eisenberg <andrew@eisenberg.as> | 2013-03-11 14:20:58 -0700 |
---|---|---|
committer | Andrew Eisenberg <andrew@eisenberg.as> | 2013-03-11 14:20:58 -0700 |
commit | f98230da890eb35c5860ee072a2845d0bc7ee092 (patch) | |
tree | 90e48fe98a9800fa2d36b1f8d7986698cd449767 | |
parent | f912b6fddae9a54f533a5b93fc4b1f42142adb0f (diff) | |
download | org.eclipse.orion.client-origin/completion-overwrite.zip org.eclipse.orion.client-origin/completion-overwrite.tar.gz org.eclipse.orion.client-origin/completion-overwrite.tar.bz2 |
Allow completions to overwrite prefixesorigin/completion-overwrite
-rw-r--r-- | bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js index 3c23655..25d631d 100644 --- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js +++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js @@ -129,15 +129,25 @@ define("orion/editor/contentAssist", ['i18n!orion/editor/nls/messages', 'orion/k if (!proposal) {
return false;
}
- var offset = this.textView.getCaretOffset();
+
+ // now handle prefixes
+ // if there is a non-empty selection, then replace it,
+ // if overwrite is truthy, then also replace the prefix
+ var sel = this.textView.getSelection();
+ var start = Math.min(sel.start, sel.end);
+ var end = Math.max(sel.start, sel.end);
+ if (proposal.overwrite) {
+ start = this.getPrefixStart(start);
+ }
+
var data = {
proposal: proposal,
- start: offset,
- end: offset
+ start: start,
+ end: end
};
this.setState(State.INACTIVE);
var proposalText = proposal.proposal || proposal;
- this.textView.setText(proposalText, offset, offset);
+ this.textView.setText(proposalText, start, end);
this.dispatchEvent({type: "ProposalApplied", data: data});
return true;
},
|