Hi Marijn,
I have been over this week trying to figure out how to send partial files (using sublime text plugin as reference) but really can't get it to work. Here is my scenario:
1. User opens big js file -- I register with tern [This works fineand I can get Autocomplete]
Current position on Editor is 390.
2. User Types 17 characters and requests autocomplete -- I take Text that was added, that is between position 390 to 407
I send the Text as well as offset which in this case (as I understand it) is position 390
3. I query the autocompletions -- I get error [Response: 400 TernError: Position 407 is outside of file.]
What do I do wrong?
Here is Whole log for this simple file I use. Also you can read it at
pastebin10:14:44: Listening on port 8000
10:14:47: Request: {
10:14:48: "files": [
10:14:48: {
10:14:49: "name": "/home/stefano/me.js",
10:14:49: "text": "var Person = Class.extend({\n init: function(isDancing){\n this.dancing = isDancing;\n },\n dance: function(){\n return this.dancing;\n }\n});\n \nvar Ninja = Person.extend({\n init: function(){\n this._super( false );\n },\n dance: function(){\n // Call the inherited version of dance()\n return this._super();\n },\n swingSword: function(){\n return true;\n }\n});\n \nvar pp = new Ninja(); ",
10:14:50: "type": "full"
10:14:50: }
10:14:51: ]
10:14:51: }
10:14:52: Response: {}
10:14:52:
10:14:58: Request: {
10:14:59: "query": {
10:14:59: "caseInsensitive": true,
10:15:00: "end": 390,
10:15:00: "file": "/home/stefano/me.js",
10:15:01: "includeKeywords": true,
10:15:01: "lineCharPositions": true,
10:15:02: "type": "completions",
10:15:02: "types": true,
10:15:03: "urls": true
10:15:03: },
10:15:04: "timeout": null
10:15:04: }
10:15:05: Response: {
10:15:05: "start": {
10:15:06: "line": 22,
10:15:06: "ch": 13
10:15:07: },
10:15:07: "end": {
10:15:08: "line": 22,
10:15:08: "ch": 18
10:15:09: },
10:15:09: "isProperty": false,
10:15:10: "isObjectKey": false,
10:15:10: "completions": [
10:15:11: {
10:15:11: "name": "Ninja",
10:15:12: "guess": true,
10:15:12: "type": "fn()"
10:15:13: }
10:15:13: ]
10:15:14: }
10:15:14:
10:15:15: Request: {
10:15:15: "files": [
10:15:16: {
10:15:16: "name": "/home/stefano/me.js",
10:15:17: "offset": 390,
10:15:17: "text": "Ninja(false);\npp.",
10:15:18: "type": "part"
10:15:18: }
10:15:19: ]
10:15:19: }
10:15:20: Response: {}
10:15:20:
10:15:21: Request: {
10:15:21: "query": {
10:15:22: "caseInsensitive": true,
10:15:22: "end": 407,
10:15:23: "file": "/home/stefano/me.js",
10:15:23: "includeKeywords": true,
10:15:24: "lineCharPositions": true,
10:15:24: "type": "completions",
10:15:25: "types": true,
10:15:25: "urls": true
10:15:26: },
10:15:26: "timeout": null
10:15:27: }
10:15:27: Response: 400 TernError: Position 407 is outside of file.