Overwriting a selection with a large block with more than 2300 lines generated by script fails

Overwriting a selection with a large block with more than 2300 lines generated by script fails

2
NewbieNewbie
2

    Jun 22, 2016#1

    UltraEdit Professional Text/HEX Editor
    Version 23.00.0.59

    I use the menu "Advanced->Play Script" to run the JavaScript "jsFormatPlus.js". (This script can format the selected JavaScript code.)

    If the reformatted JavaScript code is more than about 2300 lines, UltraEdit.activeDocument.write(code); fails to overwrite the existing selection in active file.

    Please see attachment for the script file and the example code file.
    Documents.zip (15.02 KiB)   68

    6,603548
    Grand MasterGrand Master
    6,603548

      Jun 23, 2016#2

      This is indeed an interesting issue. I could reproduce the wrong behavior on writing the large block into active file with overwriting existing selection also with UE v22.20.0.39 on Windows XP. I suggest to report this issue by email to IDM support as this is obviously a bug in code of UltraEdit.

      But I have also good news for you. There is a workaround which I use in my scripts always for writing large text blocks into a file as being faster than using write command.

      Replace in your script the 2 lines

      Code: Select all

        code = js_beautify(base_code);
        UltraEdit.activeDocument.write(code);
      by the following lines

      Code: Select all

        var nActiveClipboard = UltraEdit.clipboardIdx;
        UltraEdit.selectClipboard(9);
        UltraEdit.clipboardContent = js_beautify(base_code);
        UltraEdit.activeDocument.paste();
        UltraEdit.clearClipboard();
        UltraEdit.selectClipboard(nActiveClipboard);
      
      The large block is now pasted via user clipboard 9 into the file replacing the existing selection which works always. The contents of active clipboard is not modified except the active clipboard is user clipboard 9 and reselected before exiting the script.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Jun 23, 2016#3

        Thanks
        it works well
        I will report this bug to IDM support.