Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Completion request was ignoring the cursor position, now it's fixed
  • Loading branch information
maveme committed Sep 10, 2018
1 parent 891bed9 commit 65d9c07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -16,7 +16,7 @@ public class ContentCompleteRequest extends Content{
/**
* The cursor position within 'code' (in unicode characters) where completion is requested.
*/
private int cursorPosition;
private int cursorPos;

// -----------------------------------------------------------------
// Methods
Expand All @@ -35,7 +35,7 @@ public String getCode() {
* @return
*/
public int getCursorPosition() {
return cursorPosition;
return cursorPos;
}

}
8 changes: 4 additions & 4 deletions bacata-rascal/src/bacata/dslNotebook/DSLNotebook.java
Expand Up @@ -182,17 +182,17 @@ public void processIsCompleteRequest(Header header, ContentIsCompleteRequest req
@Override
public void processCompleteRequest(Header parentHeader, ContentCompleteRequest request, Map<String, String> metadata) {
// TODO: Check this preconditions? should they be in the language part?
int cursorStart =0;
int cursorPosition = request.getCursorPosition();
ArrayList<String> sugestions;
if(request.getCode().startsWith("import ")){
cursorStart=7;
cursorPosition=7;
}
CompletionResult result =this.language.completeFragment(request.getCode(), request.getCursorPosition());
CompletionResult result =this.language.completeFragment(request.getCode(), cursorPosition);
if(result != null)
sugestions = (ArrayList<String>)result.getSuggestions();
else
sugestions = null;
ContentCompleteReply content = new ContentCompleteReply(sugestions, cursorStart, request.getCode().length(), new HashMap<String, String>(), Status.OK);
ContentCompleteReply content = new ContentCompleteReply(sugestions, result.getOffset(), request.getCode().length(), new HashMap<String, String>(), Status.OK);
sendMessage(getCommunication().getRequests(), createHeader(parentHeader.getSession(), MessageType.COMPLETE_REPLY), parentHeader, new HashMap<String, String>(), content);
}

Expand Down

0 comments on commit 65d9c07

Please sign in to comment.