Skip to content

Commit 1caa7d3

Browse files
committed
Нормализация пути к файлу под Win
1 parent 65dd217 commit 1caa7d3

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/DebugServer/OscriptDebugSession.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public override void Disconnect(Response response, dynamic arguments)
181181

182182
public override void SetBreakpoints(Response response, dynamic arguments)
183183
{
184-
SessionLog.WriteLine("Set breakpoints command accepted");
184+
SessionLog.WriteLine($"Set breakpoints command accepted {arguments}");
185185

186186
if ((bool)arguments.sourceModified)
187187
{
@@ -196,7 +196,12 @@ public override void SetBreakpoints(Response response, dynamic arguments)
196196

197197
var path = (string) arguments.source.path;
198198
path = ConvertClientPathToDebugger(path);
199-
199+
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
200+
{
201+
// vscode иногда передает путь, где диск - маленькая буква
202+
path = NormalizeDriveLetter(path);
203+
}
204+
200205
var breaks = new List<OneScript.DebugProtocol.Breakpoint>();
201206

202207
foreach (var srcBreakpoint in arguments.breakpoints)
@@ -206,19 +211,26 @@ public override void SetBreakpoints(Response response, dynamic arguments)
206211
bpt.Source = path;
207212
breaks.Add(bpt);
208213
}
209-
210-
SessionLog.WriteLine("process exited: " + _process.HasExited);
214+
211215
var confirmedBreaks = _process.SetBreakpoints(breaks);
212216
var confirmedBreaksVSCode = new List<VSCodeDebug.Breakpoint>(confirmedBreaks.Length);
213217
for (int i = 0; i < confirmedBreaks.Length; i++)
214218
{
215219
confirmedBreaksVSCode.Add(new VSCodeDebug.Breakpoint(true, confirmedBreaks[i].Line));
216220
}
217-
221+
218222
SendResponse(response, new SetBreakpointsResponseBody(confirmedBreaksVSCode));
219223

220224
}
221225

226+
private string NormalizeDriveLetter(string path)
227+
{
228+
if (Path.IsPathRooted(path))
229+
return path[0].ToString().ToUpperInvariant() + path.Substring(1);
230+
else
231+
return path;
232+
233+
}
222234

223235
public void ThreadStopped(int threadId, ThreadStopReason reason)
224236
{
@@ -236,6 +248,13 @@ public void ProcessExited(int exitCode)
236248

237249
public override void ConfigurationDone(Response response, dynamic args)
238250
{
251+
if (_process == null)
252+
{
253+
SessionLog.WriteLine("Config Done. Process is not started");
254+
SendResponse(response);
255+
return;
256+
}
257+
SessionLog.WriteLine("Config Done. Process is started");
239258
_process.BeginExecution();
240259
_startupPerformed = true;
241260
SendResponse(response);

0 commit comments

Comments
 (0)