Skip to content

Commit beb7013

Browse files
committed
1.0.6
1 parent 28cc134 commit beb7013

5 files changed

Lines changed: 37 additions & 7 deletions

File tree

DebugAdapter/DebugSession.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ public class DebugSession : ICDPListener, IDebuggeeListener, IRemoteControllerLi
2727
{
2828
public ICDPSender toVSCode;
2929
public IDebuggeeSender toDebuggee;
30-
private Process process;
30+
Process process;
31+
RemoteController giderosRemoteController;
3132
string giderosStdoutBuffer = "";
3233
string workingDirectory;
3334
Tuple<string, int> fakeBreakpointMode = null;
3435
string startCommand;
3536
int startSeq;
3637
bool jumpToGiderosErrorPosition = false;
38+
bool stopGiderosWhenDebuggerStops = false;
3739

3840
public DebugSession()
3941
{
@@ -158,6 +160,13 @@ void SendErrorResponse(string command, int seq, int id, string format, dynamic a
158160

159161
void Disconnect(string command, int seq, dynamic arguments)
160162
{
163+
if (giderosRemoteController != null &&
164+
stopGiderosWhenDebuggerStops)
165+
{
166+
MessageBox.OK("Stopping");
167+
giderosRemoteController.SendStop();
168+
}
169+
161170
if (process != null)
162171
{
163172
try
@@ -252,11 +261,11 @@ void Launch(string command, int seq, dynamic args)
252261
}
253262
else
254263
{
255-
var rc = new RemoteController();
264+
giderosRemoteController = new RemoteController();
256265

257266
var connectStartedAt = DateTime.Now;
258267
bool alreadyLaunched = false;
259-
while (!rc.TryStart("127.0.0.1", 15000, gprojPath, this))
268+
while (!giderosRemoteController.TryStart("127.0.0.1", 15000, gprojPath, this))
260269
{
261270
if (DateTime.Now - connectStartedAt > TimeSpan.FromSeconds(10))
262271
{
@@ -298,7 +307,7 @@ void Launch(string command, int seq, dynamic args)
298307
}
299308
}
300309

301-
new System.Threading.Thread(rc.ReadLoop).Start();
310+
new System.Threading.Thread(giderosRemoteController.ReadLoop).Start();
302311
}
303312

304313
AcceptDebuggee(command, seq, args, listener);
@@ -381,6 +390,12 @@ bool ReadBasicConfiguration(string command, int seq, dynamic args)
381390
jumpToGiderosErrorPosition = true;
382391
}
383392

393+
if (args.stopGiderosWhenDebuggerStops != null &&
394+
(bool)args.stopGiderosWhenDebuggerStops == true)
395+
{
396+
stopGiderosWhenDebuggerStops = true;
397+
}
398+
384399
return true;
385400
}
386401

Extension/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.6
2+
* Added an option: stopGiderosWhenDebuggerStops
3+
14
## 1.0.5
25
* Gideros error message is highlighted.
36

Extension/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lua-debug",
33
"displayName": "Lua Debugger",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"publisher": "devCAT",
66
"icon": "images/icon.png",
77
"description": "Visual Studio Code debugger extension for Lua 5.1",
@@ -54,6 +54,7 @@
5454
"giderosPath": "C:/Program Files (x86)/Gideros",
5555
"gprojPath": "${workspaceRoot}/GPROJ.gproj",
5656
"jumpToGiderosErrorPosition": false,
57+
"stopGiderosWhenDebuggerStops": true,
5758
"listenPublicly": false,
5859
"listenPort": 56789,
5960
"encoding": "UTF-8"
@@ -123,6 +124,11 @@
123124
"type": "boolean",
124125
"description": "Sets whether to jump directly to the source file if it encounters a Gideros error message.",
125126
"default": false
127+
},
128+
"stopGiderosWhenDebuggerStops": {
129+
"type": "boolean",
130+
"description": "Stops Gideros Player when debug adapter stops.",
131+
"default": false
126132
}
127133
}
128134
},

GiderosPlayerRemote/RemoteController.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ void Play()
403403

404404
UpdateMD5();
405405

406-
NewMessage(GiderosMessageType.Stop)
407-
.Send();
406+
SendStop();
408407

409408
NewMessage(GiderosMessageType.SetProjectName)
410409
.AppendString(Path.GetFileNameWithoutExtension(projectFileName))
@@ -414,6 +413,12 @@ void Play()
414413
.Send();
415414
}
416415

416+
public void SendStop()
417+
{
418+
NewMessage(GiderosMessageType.Stop)
419+
.Send();
420+
}
421+
417422
void UpdateMD5()
418423
{
419424
//var begin = DateTime.Now;

debuggee/.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"workingDirectory": "${workspaceRoot}",
2020
"giderosPath": "C:/Program Files (x86)/Gideros",
2121
"gprojPath": "${workspaceRoot}/gideros.gproj",
22+
"stopGiderosWhenDebuggerStops": true,
2223
"listenPublicly": false,
2324
"listenPort": 56789,
2425
"encoding": "UTF-8"

0 commit comments

Comments
 (0)