UltraEdit.activeDocumentIdx with many open files has wrong document index number (fixed)

UltraEdit.activeDocumentIdx with many open files has wrong document index number (fixed)

3

    Feb 17, 2018#1

    I need to work with more than 10 open documents.

    UltraEdit.activeDocumentIdx never gives values higher than 10, so I have problems to jump from one file to another.

    An example to identify my problem:

    Code: Select all

    var idxDocument=0;
    for (var i=0; i<12; i++)
    {
       UltraEdit.newFile();
       idxDocument=UltraEdit.activeDocumentIdx;
       UltraEdit.outputWindow.write("Open document:"+UltraEdit.document.length+" Document IDX:"+idxDocument+" "+UltraEdit.document[idxDocument].path);
    }

    6,613548
    Grand MasterGrand Master
    6,613548

      Feb 17, 2018#2

      Good script!

      Which version of UltraEdit do you use?

      I tried to reproduce this issue with 32-bit English UltraEdit v22.20.0.49 on Windows XP and with 32-bit English UltraEdit v24.20.0.62 on Windows 7 and failed. All the lines in output window showed right data on all my test runs with various GUI modes (ribbon mode, contemporary menus, traditional menus), with file tabs bar shown/hidden, with dockable and not dockable file tabs, with new files being ANSI, UTF-8, or UTF-16 encoded, with new files being DOS/UNIX/MAC files.

      The value of UltraEdit.activeDocumentIdx assigned to idxDocument and used on line writing to output window was right also for the the files with document index greater 9.
      Best regards from an UC/UE/UES for Windows user from Austria

      3

        Feb 17, 2018#3

        I use UE 24.20.0.62 x64 in Windows 10 64-bit

        In Windows 7 32-bit with same version of UE 24.20 32-bit something better works.
        win7x32.JPG (64.78KiB)
        w10.JPG (53.06KiB)

        11327
        MasterMaster
        11327

          Feb 18, 2018#4

          I've the same issue as eduardo.canadas, even with clean INI files. UE 24.20.0.62 x64 / Windows 7 SP1

          Code: Select all

          Open document:1 Document IDX:0 Edit1
          Open document:2 Document IDX:1 Edit2
          Open document:3 Document IDX:2 Edit3
          Open document:4 Document IDX:3 Edit4
          Open document:5 Document IDX:4 Edit5
          Open document:6 Document IDX:5 Edit6
          Open document:7 Document IDX:6 Edit7
          Open document:8 Document IDX:7 Edit8
          Open document:9 Document IDX:8 Edit9
          Open document:10 Document IDX:9 Edit10
          Open document:11 Document IDX:10 Edit11
          Open document:12 Document IDX:11 Edit12
          Open document:13 Document IDX:12 Edit13
          Open document:14 Document IDX:13 Edit14
          Open document:15 Document IDX:13 Edit14
          Open document:16 Document IDX:12 Edit13
          Open document:17 Document IDX:13 Edit14
          Open document:18 Document IDX:11 Edit12
          Open document:19 Document IDX:12 Edit13
          Open document:20 Document IDX:13 Edit14
          With clean INI files:

          Code: Select all

          Open document:1 Document IDX:0 Edit1
          Open document:2 Document IDX:1 Edit2
          Open document:3 Document IDX:2 Edit3
          Open document:4 Document IDX:3 Edit4
          Open document:5 Document IDX:4 Edit5
          Open document:6 Document IDX:5 Edit6
          Open document:7 Document IDX:6 Edit7
          Open document:8 Document IDX:7 Edit8
          Open document:9 Document IDX:8 Edit9
          Open document:10 Document IDX:9 Edit10
          Open document:11 Document IDX:10 Edit11
          Open document:12 Document IDX:11 Edit12
          Open document:13 Document IDX:12 Edit13
          Open document:14 Document IDX:13 Edit14
          Open document:15 Document IDX:14 Edit15
          Open document:16 Document IDX:15 Edit16
          Open document:17 Document IDX:16 Edit17
          Open document:18 Document IDX:16 Edit17
          Open document:19 Document IDX:15 Edit16
          Open document:20 Document IDX:16 Edit17
          I've found that UltraEdit.activeDocumentIdx is affected by Configuration->Application Layout->Miscellaneous->Sort tabs on file open.
          When this setting is checked, the same index may be assigned to different documents when a name of the file is being processed starts with a letter "greater" than "E" (F and so on) or whole file name is "greater" than editxx (xx - numbers). 

          Simple sample script :-)

          Code: Select all

          UltraEdit.outputWindow.showWindow(true);
          src = UltraEdit.activeDocumentIdx;
          UltraEdit.outputWindow.write(src.toString(10));
          UltraEdit.newFile();
          dst = UltraEdit.activeDocumentIdx;
          UltraEdit.outputWindow.write(dst.toString(10));
          Add this script  to script list, close any documents, open this script in UE as test file and run script. Then both indices would be 0.
          It's impossible to lead us astray for we don't care even to choose the way.

          6,613548
          Grand MasterGrand Master
          6,613548

            Feb 18, 2018#5

            I can reproduce this issue with UltraEdit v24.00.0.42 to v24.20.0.62 with opening 20 new files instead of just 12 independent on Sort File Tabs state.

            This issue does not exist with UE v22.20.0.49 or any former version. So it is obviously a bug introducing on recoding UltraEdit for ribbon interface.

            Please report this bug by email to IDM support as I have done too.

            It is possible as workaround to use the function GetFileIndex, but without the optimization of using UltraEdit.activeDocumentIdx and optimized to get document index number of active file.

            Code: Select all

            function GetFileIndex ()
            {
               // Compare the name of active file with the file names of all already
               // opened files. Return the document index of active file on being found.
               for (var nDocIndex = 0; nDocIndex < UltraEdit.document.length; nDocIndex++)
               {
                  if (UltraEdit.document[nDocIndex].path == UltraEdit.activeDocument.path)
                  {
                     return nDocIndex;
                  }
               }
            }
            
            var idxDocument=0;
            for (var i=0; i<20; i++)
            {
               UltraEdit.newFile();
               idxDocument=GetFileIndex();
               UltraEdit.outputWindow.write("Open document:"+UltraEdit.document.length+" Document IDX:"+idxDocument+" "+UltraEdit.document[idxDocument].path);
            }
            
            Best regards from an UC/UE/UES for Windows user from Austria

            11327
            MasterMaster
            11327

              Feb 18, 2018#6

              2Mofi

              Thank you for workaround!

              I'll write to IDM about these two issues tomorrow, that's for sure!
              It's impossible to lead us astray for we don't care even to choose the way.

              3

                Feb 18, 2018#7

                Thanks

                11327
                MasterMaster
                11327

                  Re: UltraEdit.activeDocumentIdx with many open files has wrong document index number

                  Feb 19, 2018#8

                  I've got an answer from the IDM support to both issues:
                  IDM support wrote:Thank you for your message and the attached script. I can reproduce the issue you've described and will ask our developers to investigate and correct this.
                  It's impossible to lead us astray for we don't care even to choose the way.

                  6,613548
                  Grand MasterGrand Master
                  6,613548

                    Mar 16, 2018#9

                    The bug with UltraEdit.activeDocumentIdx returning wrong document index number is fixed with UE v25.00 and UES v18.00.
                    Best regards from an UC/UE/UES for Windows user from Austria