Skip to content

Commit

Permalink
reapply our hacks for R completion to new ace source
Browse files Browse the repository at this point in the history
fixes #352

reapplies the changes in commits 4b0cf87, 58186b1, c7d7c29
  • Loading branch information
gordonwoodhull committed Mar 22, 2014
1 parent acea6e9 commit d4a31cd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
21 changes: 16 additions & 5 deletions htdocs/lib/ace_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17728,6 +17728,13 @@ define('ace/mode/r', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/oop
{
this.HighlightRules = RHighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.getCompletions = function(state, session, pos, prefix, callback) {
rcloud.get_completions(session.getValue(),
session.getDocument().positionToIndex(pos))
.then(function(ret) {
callback(null, ret);
});
};
};
oop.inherits(Mode, TextMode);

Expand Down Expand Up @@ -22617,8 +22624,9 @@ var textCompleter = require("../autocomplete/text_completer");
var keyWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
var state = editor.session.getState(pos.row);
var completions = session.$mode.getCompletions(state, session, pos, prefix);
callback(null, completions);
// gw: pass in callback instead of calling it directly, to support asynchronous results
var completions = session.$mode.getCompletions(state, session, pos, prefix, callback);
//callback(null, completions);
}
};

Expand Down Expand Up @@ -23659,7 +23667,8 @@ var Autocomplete = function() {
data.completer.insertMatch(this.editor);
} else {
if (this.completions.filterText) {
var ranges = this.editor.selection.getAllRanges();
// gw: getAllRanges comes up blank, so it doesn't replace (??)
var ranges = [this.editor.selection.getRange()]; // this.editor.selection.getAllRanges();
for (var i = 0, range; range = ranges[i]; i++) {
range.start.column -= this.completions.filterText.length;
this.editor.session.remove(range);
Expand Down Expand Up @@ -24171,7 +24180,8 @@ exports.parForEach = function(array, fn, callback) {
}
}

var ID_REGEX = /[a-zA-Z_0-9\$-]/;
// gw: add \. to identifiers for R
var ID_REGEX = /[a-zA-Z_0-9\$-\.]/;

exports.retrievePrecedingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX;
Expand Down Expand Up @@ -24245,7 +24255,8 @@ define('ace/autocomplete/text_completer', ['require', 'exports', 'module' , 'ace
(function() {
window.require(["ace/ext/language_tools"], function() {});
})();
/* ***** BEGIN LICENSE BLOCK *****

/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
Expand Down
12 changes: 6 additions & 6 deletions htdocs/lib/ace_bundle.min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions htdocs/lib/js/ace/ext-language_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ var textCompleter = require("../autocomplete/text_completer");
var keyWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
var state = editor.session.getState(pos.row);
var completions = session.$mode.getCompletions(state, session, pos, prefix);
callback(null, completions);
// gw: pass in callback instead of calling it directly, to support asynchronous results
var completions = session.$mode.getCompletions(state, session, pos, prefix, callback);
//callback(null, completions);
}
};

Expand Down Expand Up @@ -1081,7 +1082,8 @@ var Autocomplete = function() {
data.completer.insertMatch(this.editor);
} else {
if (this.completions.filterText) {
var ranges = this.editor.selection.getAllRanges();
// gw: getAllRanges comes up blank, so it doesn't replace (??)
var ranges = [this.editor.selection.getRange()]; // this.editor.selection.getAllRanges();
for (var i = 0, range; range = ranges[i]; i++) {
range.start.column -= this.completions.filterText.length;
this.editor.session.remove(range);
Expand Down Expand Up @@ -1593,7 +1595,8 @@ exports.parForEach = function(array, fn, callback) {
}
}

var ID_REGEX = /[a-zA-Z_0-9\$-]/;
// gw: add \. to identifiers for R
var ID_REGEX = /[a-zA-Z_0-9\$-\.]/;

exports.retrievePrecedingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX;
Expand Down Expand Up @@ -1667,4 +1670,4 @@ define('ace/autocomplete/text_completer', ['require', 'exports', 'module' , 'ace
(function() {
window.require(["ace/ext/language_tools"], function() {});
})();


7 changes: 7 additions & 0 deletions htdocs/lib/js/ace/mode-r.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ define('ace/mode/r', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/oop
{
this.HighlightRules = RHighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.getCompletions = function(state, session, pos, prefix, callback) {
rcloud.get_completions(session.getValue(),
session.getDocument().positionToIndex(pos))
.then(function(ret) {
callback(null, ret);
});
};
};
oop.inherits(Mode, TextMode);

Expand Down

0 comments on commit d4a31cd

Please sign in to comment.