- [NEW] Expressions evaluables desde la consola de vscode
- [FIX] Ara els breakpoints que hi havia abans de llançar la aplicació ja es tenen en compte - [FIX] Ja no fa falta apretar dos vegades el botó de parar en vscode
This commit is contained in:
@@ -28,6 +28,8 @@ constructor() {
|
|||||||
this._pendingGlobals = null;
|
this._pendingGlobals = null;
|
||||||
this._refTable = new Map(); // ref → { luaRef }
|
this._refTable = new Map(); // ref → { luaRef }
|
||||||
this._nextRef = 1000; // IDs únicos para tablas
|
this._nextRef = 1000; // IDs únicos para tablas
|
||||||
|
this._pendingEval = null;
|
||||||
|
this.programStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//initializeRequest(response, args) {
|
//initializeRequest(response, args) {
|
||||||
@@ -193,6 +195,29 @@ constructor() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (json.type === "eval") {
|
||||||
|
const r = this._pendingEval;
|
||||||
|
this._pendingEval = null;
|
||||||
|
|
||||||
|
const v = json.payload.result;
|
||||||
|
|
||||||
|
let variablesReference = 0;
|
||||||
|
|
||||||
|
if (v.type === "table" && v.ref > 0) {
|
||||||
|
const id = this._nextRef++;
|
||||||
|
this._refTable.set(id, v.ref);
|
||||||
|
variablesReference = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
r.body = {
|
||||||
|
result: v.value,
|
||||||
|
variablesReference
|
||||||
|
};
|
||||||
|
|
||||||
|
this.sendResponse(r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// salida normal
|
// salida normal
|
||||||
this.sendEvent(new OutputEvent(line + "\n", "stdout"));
|
this.sendEvent(new OutputEvent(line + "\n", "stdout"));
|
||||||
}
|
}
|
||||||
@@ -207,8 +232,7 @@ constructor() {
|
|||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
stdio: ['pipe', 'pipe', 'pipe']
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
|
this.programStarted = true;
|
||||||
this.sendEvent(new ThreadEvent("started", 1));
|
|
||||||
|
|
||||||
this.stdoutBuffer = "";
|
this.stdoutBuffer = "";
|
||||||
|
|
||||||
@@ -232,6 +256,21 @@ constructor() {
|
|||||||
this.sendEvent(new TerminatedEvent());
|
this.sendEvent(new TerminatedEvent());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 3. Ahora que stdout ya está conectado, enviar breakpoints
|
||||||
|
if (this.breakpoints) {
|
||||||
|
for (const path in this.breakpoints) {
|
||||||
|
const lines = this.breakpoints[path];
|
||||||
|
|
||||||
|
this.sendDebugCommand({
|
||||||
|
cmd: "setBreakpoints",
|
||||||
|
file: path,
|
||||||
|
lines: lines
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sendEvent(new ThreadEvent("started", 1));
|
||||||
|
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +297,36 @@ constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setBreakPointsRequest(response, args) {
|
setBreakPointsRequest(response, args) {
|
||||||
|
const path = args.source.path;
|
||||||
|
const clientBreakpoints = args.breakpoints || [];
|
||||||
|
|
||||||
|
const lines = clientBreakpoints.map(bp => bp.line);
|
||||||
|
|
||||||
|
if (!this.breakpoints)
|
||||||
|
this.breakpoints = {};
|
||||||
|
|
||||||
|
this.breakpoints[path] = lines;
|
||||||
|
|
||||||
|
// Si el programa YA está corriendo → enviar breakpoints al motor
|
||||||
|
if (this.programStarted) {
|
||||||
|
this.sendDebugCommand({
|
||||||
|
cmd: "setBreakpoints",
|
||||||
|
file: path,
|
||||||
|
lines: lines
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
response.body = {
|
||||||
|
breakpoints: lines.map(line => ({
|
||||||
|
verified: true,
|
||||||
|
line: line
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
|
||||||
|
this.sendResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*setBreakPointsRequest(response, args) {
|
||||||
const path = args.source.path; // archivo donde se han puesto breakpoints
|
const path = args.source.path; // archivo donde se han puesto breakpoints
|
||||||
const clientBreakpoints = args.breakpoints || [];
|
const clientBreakpoints = args.breakpoints || [];
|
||||||
|
|
||||||
@@ -291,7 +360,7 @@ constructor() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
continueRequest(response, args) {
|
continueRequest(response, args) {
|
||||||
const msg = {
|
const msg = {
|
||||||
@@ -344,11 +413,40 @@ constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disconnectRequest(response, args) {
|
disconnectRequest(response, args) {
|
||||||
const msg = { cmd: "continue" }; // por si estaba pausado
|
console.log("[ADAPTER] disconnectRequest");
|
||||||
this.sendDebugCommand(msg);
|
|
||||||
//this.process.stdin.write("@@DEBUGCMD@@" + JSON.stringify(msg) + "\n");
|
|
||||||
|
|
||||||
this.process.kill();
|
if (this.process) {
|
||||||
|
try {
|
||||||
|
// 1. Cerrar stdin para desbloquear lecturas
|
||||||
|
this.process.stdin.end();
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 2. Intento de kill suave
|
||||||
|
this.process.kill();
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 3. Kill duro por si acaso
|
||||||
|
this.process.kill('SIGKILL');
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Notificar a VSCode
|
||||||
|
this.sendEvent(new TerminatedEvent());
|
||||||
|
this.sendResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
terminateRequest(response, args) {
|
||||||
|
console.log("[ADAPTER] terminateRequest");
|
||||||
|
|
||||||
|
if (this.process) {
|
||||||
|
try { this.process.stdin.end(); } catch (e) {}
|
||||||
|
try { this.process.kill(); } catch (e) {}
|
||||||
|
try { this.process.kill('SIGKILL'); } catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sendEvent(new TerminatedEvent());
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +549,17 @@ constructor() {
|
|||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evaluateRequest(response, args) {
|
||||||
|
console.log("[ADAPTER] evaluateRequest:", args.expression);
|
||||||
|
|
||||||
|
this._pendingEval = response;
|
||||||
|
|
||||||
|
this.sendDebugCommand({
|
||||||
|
cmd: "eval",
|
||||||
|
expr: args.expression
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
configurationDoneRequest(response, args) {
|
configurationDoneRequest(response, args) {
|
||||||
console.log("[ADAPTER] configurationDoneRequest");
|
console.log("[ADAPTER] configurationDoneRequest");
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
|
|||||||
Reference in New Issue
Block a user