Several bug fixes.

This commit is contained in:
2014-11-03 23:37:34 +01:00
parent 1414d634fd
commit b1ab5822a7
4 changed files with 91 additions and 36 deletions

View File

@@ -59,10 +59,22 @@ function Buffer (client, buffId) {
};
//Tell Vim that the buffer is owned by the controler
//Réception d'événéments si vrai
this.netbeansBuffer = function (isNetBeansBuffer) {
client.sendCommand("netbeansBuffer", buffId, Types.bool(isNetBeansBuffer));
};
//Start an atomic opperation. Vim screen is not updated untill endAtomic is called
//BUG : Interprété comme un startDocumentListen
this.startAtomic = function () {
client.sendCommand("startAtomic", buffId);
};
//End an atomic opperation.
//BUG : Ne fais rien du tout
this.endAtomic = function() {
client.sendCommand("endAtmoic", buffId );
};
//Remove and anno
this.removeAnno = function (serNum) {
client.sendCommand("removeAnno",buffId,serNum);
@@ -119,6 +131,7 @@ function Buffer (client, buffId) {
};
//Ungard the text. off is the starting position, len the length of the text
//BUG : Doesn't works at all, text area keeps guard
this.unguard = function (off, len) {
client.sendCommand("unguard", buffId, Types.position(off), len);
};
@@ -128,23 +141,10 @@ function Buffer (client, buffId) {
client.sendCommand("editFile", buffId, Types.string(pathName));
};
//Start an atomic opperation. Vim screen is not updated untill endAtomic is called
this.startAtomic = function () {
client.sendCommand("startAtomic", buffId);
};
//End an atomic opperation.
this.endAtomic = function() {
client.sendCommand("endAtmoic", buffId);
};
/* FUNCTIONS */
//Get cursor position. Callback function get the line, column and offset
this.getCursor = function (callback) {
client.callFunction("getCursor", buffId, callback);
};
//Get the length of current buffer.
this.getLength = function (callback) {

View File

@@ -114,7 +114,7 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
if (message[i] === "\\") {
i += 1;
if (i < message.length) {
if (i === message.length) {
throw "Unfinished string in message";
}
else {
@@ -155,11 +155,11 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
i += 1;
}
if (i - argStartOffset === 1 && (message[i] === "T" || message[i] === "F")) {
args.push(message[i] === "T");
if (i - argStartOffset === 1 && (message[i - 1] === "T" || message[i - 1] === "F")) {
args.push(message[i - 1] === "T");
}
else {
var argument = message.substr(argStartOffset, i);
var argument = message.substring(argStartOffset, i);
if (Number.isNaN(argument)) {
if (argument.contains("/")) {
@@ -170,10 +170,13 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
}
}
else {
console.log("ARG : "+argument);
args.push(parseInt(argument));
}
}
}
argStartOffset = ++i;
}
if (isEvent) {
@@ -237,18 +240,20 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
var lastArg = arguments.length - 1;
if (typeof(arguments[lastArg]) === "function") {
Object.defineProperty(callbacks, currentSeqno, {value: arguments[lastArg]});
Object.defineProperty(callbacks, seqno, {value: arguments[lastArg], configurable: true});
lastArg -= 1;
}
var data = buffer + ":" + name + "/" + seqno;
for (var i = 2 ; i < lastArg ; ++i) {
for (var i = 2 ; i <= lastArg ; ++i) {
data += " " + arguments[i];
}
data += "\n";
console.log("CALL : "+data);
socket.write(data);
};
@@ -303,10 +308,10 @@ function Controler(socket, authentication) {
var buffId = 0;
var buffers = {};
function getBuffer() {
function newBuffer() {
buffId += 1;
var buffer = new Buffer(client, buffId);
Object.defineProperty(buffers, buffId, {value: buffer});
Object.defineProperty(buffers, buffId, {value: buffer, configurable: true});
return buffer;
}
@@ -330,7 +335,7 @@ function Controler(socket, authentication) {
//Create a new buffer. Return the buffer created
this.create = function() {
var buffer = getBuffer();
var buffer = newBuffer();
client.sendCommand("create", buffId);
return buffer;
};
@@ -338,7 +343,7 @@ function Controler(socket, authentication) {
//Associate already opened buffer on Vim to a controler owned buffer
//Return the newly created buffer
this.putBufferNumber = function (pathname) {
var buffer = getBuffer();
var buffer = newBuffer();
client.sendCommand("putBufferNumber", buffId, Types.string(pathname)); //TODO : May be better on the buffer
return buffer;
};
@@ -346,11 +351,12 @@ function Controler(socket, authentication) {
//Associate already opened buffer on Vim to a controler owned buffer and bring it to front
//Return the newly created buffer
this.setBufferNumber = function (pathname) {
var buffer = getBuffer();
var buffer = newBuffer();
client.sendCommand("setBufferNumber", buffId, Types.string(pathname));
return buffer;
};
/* GLOBAL FUNCTIONS */
//Ask Vim to save and exit
@@ -363,6 +369,10 @@ function Controler(socket, authentication) {
client.callFunction("getModified", 0, callback);
};
//Get cursor position. Callback function get the line, column and offset
this.getCursor = function (callback) {
client.callFunction("getCursor", 0, callback);
};
/* CONNTROLER CONTROL */