Wish Ignore formatting block

stevel05

Expert
Licensed User
Longtime User
It would be useful to be able to specify a block of code in the IDE that should be ignored by the formatting parser. I have been working on some javascript injections in a smart string, but every time the smartstring is broken, for instance when adding a new variable, the block is formatted and any shared keywords or variable names can end up with a capital first letter, which then breaks the javascript. For instance:
B4X:
                    Dim Script As String = $"
        function setCursorPos(){
        
        var el = document.getElementsByClassName("${ACTIVE_ELEMENT_CLASS}$");
        var selection;
        if (window.getSelection) {
        selection = window.getSelection();
        } else if (document.selection && document.selection.type != "Control") {
        selection = document.selection;}
        var el = selection.anchorNode;
        if(el){
             if (el.nodeType == Node.TEXT_NODE){
             do {
                     el = el.parentElement;
                } while (el.nodeType == Node.TEXT_NODE);
             }
                el.classList.add("${ACTIVE_ELEMENT_CLASS}");
            }
        return selection.anchorOffset;
    }"$

becomes

B4X:
    Dim Script As String = $"
        function setCursorPos(){
        
        var el = document.getElementsByClassName("${ACTIVE_ELEMENT_CLASS}$");
        var selection;
        if (window.getSelection) {
        selection = window.getSelection();
        } else if (document.selection && document.selection.type != "Control") {
        selection = document.selection;}
        var el = selection.anchorNode;
        if(el == ${){
             If (el.nodeType == Node.TEXT_NODE){
             Do {
                     el = el.parentElement;
                } while (el.nodeType == Node.TEXT_NODE);
             }
                el.classList.add("${ACTIVE_ELEMENT_CLASS}");
            }
        return selection.anchorOffset;
    }"$

While making a change to line 11, the I in if and the D in do on the next lines are capitalized.

It's not huge, just inconvenient especially when it's a large block of code, it's easy to miss a couple of changes only to find out when compiling. I can get round it by copying the string to another editor and then pasting it back, but it's a pain.
 
Top