monaco-languageclient
monaco-languageclient copied to clipboard
Is there a way to add a prefix to the code before sending to server?
I need to add some prefix (imports) to the code before sending to server but I don't want those imports to be a part of the code string that displays in the editor. Is there a way to pass the codestring through a method before it's sent to the server?
I don't think it's the proper way to do it, it will cause numerous issues by shifting line number references.
A better hack would be to hide those lines in the editor, it can be achieved using the internal setHiddenAreas editor api (this api is used by the code folding feature, if you call it, it will override everything, be careful)
We implemented it that way at CodinGame:
- We add a decoration on the visible part (using the
deltaDecorationsmethod) - We use this function to hide the decorated part
Btw, it's often not a good idea to hide some part of the code, it can be really confusing for the user
@SharmaAjay19 I am closing the issue. If there are further questions please open a discussion: https://github.com/TypeFox/monaco-languageclient/discussions
Thank you