monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Is there a way to add a prefix to the code before sending to server?

Open SharmaAjay19 opened this issue 3 years ago • 1 comments

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?

SharmaAjay19 avatar Dec 26 '21 02:12 SharmaAjay19

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 deltaDecorations method)
  • 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

CGNonofr avatar Jan 03 '22 09:01 CGNonofr

@SharmaAjay19 I am closing the issue. If there are further questions please open a discussion: https://github.com/TypeFox/monaco-languageclient/discussions

Thank you

kaisalmen avatar Oct 19 '22 06:10 kaisalmen