Open SchoofsKelvin opened 3 years ago
I found this issue while trying to find out how checksums
worked. There's not much info in the spec about it ("The checksums associated with this file.") or what the client should do.
I'm interested in something like the above.. in particular I'd like to have VS Code use sources from disk when they match what's in the runtime (because if we download from the VM, the user sees two copies of the same file and has two sets of breakpoints and it's not clear why), but use downloaded source if they don't match (although this raises some questions about breakpoints).
I can't any mention in the VS Code API docs about checksums.
@weinand is it possible to implement anything at all like this today (for example just avoiding confusion from sources on disk not matching what's in the runtime)?
It would be nice to have it. We've hit similar issues with Python debugging, so now there's logic in place there to report "path" only even when source is actually retrievable. It would be nice to be able to report both and let the client decide smartly on which one is the most appropriate.
I also had a related perspective on this:
Also related #407
It is nice for debugging. Bring it on
It'd be nice if a new field (e.g.
preference
) gets added toDebugProtocol.Source
to tell clients (IDEs) that if the Source can be mapped to a file, it should open that file instead of usingsourceReference
. Perhaps it's even worth making this the default, especially when combined with my item ofchecknotes
below.Details
sourceReference
bigger than 0 means that should be used, regardless ofpath
.path
ifchecksums
is present to validate whether it results in the correct file (contents).Source
can be mapped to the actual source file, instead of a snapshot in the debugger.checksums
to validate whether it is (the correct version of) the correct file. If not, revert tosourceReference
.sources
field but this isn't (meant as) a 1-on-1 mapping of the source itself.path
is not enough:checksums
isn't present), the IDE might display an outdated (or completely wrong) file.checksums
is present, the IDE can validate whether the file (content) is correct, but not fallback to anything if it isn't.This is mostly a big quality-of-life improvement towards IDE users, as these would now prefer the actual source files over cached versions provided by the debug adapter, assuming they're the same (using
checksums
). While the file content will be the exact same, mapping to an editable source file or mapping to a read-only "debug content file" is quite a large difference.Hotreload example
Since this would still allow different
Source
s with the samepath
but a differentsourceReference
/checksums
(and the IDE automatically picking between showing thepath
file or the read-onlysourceReference
viewer), we can also easily allow debug adapters to differentiate different versions of the same (path-specified) file, e.g. because of hotreloading:a.js
withAAA
as checksum.{ path: 'a.js', sourceReference: 1, checksum: ['AAA'] }
.a.js
, validates the checksum and opens it.BBB
as checksum.{ path: 'a.js', sourceReference: 2, checksum: ['BBB'] }
.AAA
).sourceReference
with value1
.BBB
) after it was saved, but before the hotreload.sourceReference
with value2
.Of course, this hotreload example is an advanced use case this change would allow. Just the QoL improvement to open the true (editable) source file instead of a snapshot if possible is already a very nice use case this allows.