mlxprs
mlxprs copied to clipboard
Debug cursor off-by-1 caused by "cache buster" line, sometimes
Sometimes the modules stored in MarkLogic have an extra line of text at the beginning, going something like:
(: cache buster: 8fc65705-e192-4c91-b988-a5bc86bec663 :)
xquery version "1.0-ml";
module namespace example = http://example.com;
(: etc... :)
The dbg:stack() command tells you the line you're on according to the server version of the module.
So, if you have the equivalent module local inside your current project, it will not include the "cache buster" line. The reported line number from debug:stack() will be 1 greater than what should be displayed in VS Code.
Except in these cases, where dbg:stack() will report the correct line number:
- if you don't have the module locally, its content will be fetched from the server to display in VS Code, including the "cache buster" line.
- if you are the top of the stack from a "launch" configuration, the query will not have a server-side version.
- Also, sometimes, there is not a "cache buster" line in the server module. I don't know what determines this.
The VS Code debugging logic should know which of these cases apply, and display the correct line to the user.