Unpredictable behavior of Document.SetActiveSegmentPair when document is a multi-file view.

The Document.SetActiveSegmentPair seems to behave unpredictably when multiple files are opened in a merged document by selecting multiple files in the Files view and choosing Open for Translation.

Sometimes the segment count starts counting at the very beginning of the merged view (that would be the expected behavior), sometimes it starts counting any of the contained files.  For example, if you run Document.SetActiveSegmentPair("4"), the cursor might go to the 4th segment of any of the files contained in the merged view, which effectively means that you put the cursor on a random segment pair.

My expectation would be that the segment number starts counting always at the first file in the view and that proceeds in the order of the files returned by Document.Files.

That is, if Document.Files returns "File1", "File2", and "File3" (in this order), and "Files1", "Files2" and "Files3" have 10 segments each, then I would expect that:

- Document.SetActiveSegmentPair("4") puts the cursor on the 4th segment of "File1".

- Document.SetActiveSegmentPair("14") puts the cursor on the 4th segment of "File2".

- Document.SetActiveSegmentPair("24") puts the cursor on the 4th segment of "File3".

Is this a bug in Document.SetActiveSegmentPair or am I missing anything on how the API should be used for merged views?

Regards,

Josep.

Parents
  • Looking closer into it, it seems that Document.SetActiveSegmentPair positions the cursor on the first file of the multi-file document that is able to position that segment number requested.

    So if File1 has 3 segments and File2 has 6 segments, Document.SetActiveSegmentPair("5") will position the cursor in segment 5 of File2.

    But I think that this is a wrong behavior for SetActiveSegmentPair because, with this approach, segments 1, 2 and 3 of File2 are not addressable by Document.SetActiveSegmentPair with 1, 2, or 3 as argument becuase that will always open the three segments in File1, not File2.

    Regards,

    Josep.

Reply
  • Looking closer into it, it seems that Document.SetActiveSegmentPair positions the cursor on the first file of the multi-file document that is able to position that segment number requested.

    So if File1 has 3 segments and File2 has 6 segments, Document.SetActiveSegmentPair("5") will position the cursor in segment 5 of File2.

    But I think that this is a wrong behavior for SetActiveSegmentPair because, with this approach, segments 1, 2 and 3 of File2 are not addressable by Document.SetActiveSegmentPair with 1, 2, or 3 as argument becuase that will always open the three segments in File1, not File2.

    Regards,

    Josep.

Children