Fix source transformation resolution, JSON deserialization, & transformed source position mapping #1335
+115
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into a few issues consecutively when attempting to use the plugins feature:
Any time a non-empty edits table was returned from a plugin's
transformSourcecallback, the process for viewing the internal source would break. This told me that something relevant to transforming the source from the edits was breaking. The fix for this was to extract the transformed source prior topluginDocand then map the transformed source into the document.When using
lsp.json.deserialize(), deserializing mysourcemap.jsonwas causing an unexpected stack overflow for the table returned by deserialization. The fix to the error being emitted internally byluau-lspbelow was to check if there's space on the stack:lapi.cpp(813): ASSERTION FAILED: L->top < L->ci->topTextDocuments andPluginTextDocuments would reference the transformed source'sLocationdata to act as a source for thecompletions,definitions,diagnostics,inlayHints, andsignatureHelpfeatures - which led to the error listed below being emitted internally byluau-lspfor each feature, respectively. The fix was to return the original source'sLocationdata instead.Received response 'textDocument/[...] - (297)' in 3ms. Request failed: invalid string position (-32603)Some notes: