Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22457
    Patrick C
    Participant

    For the following selection:
    One line selected

    When selected with line selection mode (eeModeLine)
    TopPointY = 3 | BottomPointY = 4 | ActivePointY = 3 | AnchorPointY = 3

    But when selected with stream selection mode (eeModeStream), including the newline symbol as in the image above
    TopPointY = 3 | BottomPointY = 3 | ActivePointY = 3 | AnchorPointY = 3

    Why this inconsistency in BottomPointY ?

    Is it a bug or intended? – Either of which will have implications on the future compatibility of my code.

    —————————————————————————————————————————————————–

    The strange behaviour btw. goes on:
    two lines selected

    When selected with line selection mode (eeModeLine)
    TopPointY = 2 | BottomPointY = 4 | ActivePointY = 2 | AnchorPointY = 4
    Interestingly the anchor point now too extends to line 4, despite line 4 not being selected.

    When selected with stream selection mode (eeModeStream), including the newline symbol as in the image above
    TopPointY = 2 | BottomPointY = 3 | ActivePointY = 3 | AnchorPointY = 2

    I would prefer if both selection modes would have the same behaviour when run on what basically is the ‘same’ selection (other than its mode)

    —————————————————————————————————————————————————–
    On the last line (end of document) there is even more odd behaviour:

    When the last line (end of document) contains some text, then the BottomPointY in line selection mode makes sense:
    last line with text
    TopPointY = 3 | BottomPointY = 3 | ActivePointY = 3 | AnchorPointY = 3

    But when the last line doesn’t contain text (empty string) and is selected by line selection mode:
    last line empty string line selected
    TopPointY = 3 | BottomPointY = 4 | ActivePointY = 3 | AnchorPointY = 3

    I.e. the BottomPointY now extends beyond the document!?

    —————————————————————————————————————————————————–
    I could go on with more examples of this odd behaviour, but presently I would appreciate to know if this behaviour is intended or a bug.

    Patrick

    #22458
    Patrick C
    Participant

    Ok, figured out one consistency in this:
    If the last character of the selection is a newline character (or the last two are CR+LF), then BottomPointY will be one line below the actual selection.

    With one exception:
    When the last line is empty but line-selected,
    last line empty + line selected
    then the last character of that selection is not a new line character but BottomPointY still is one line beyond the end of the selection.

    Provided future EmEditor versions will continue to have have this BottomPointY behavior, my issue should be solved as I now can simply test whether the last character is new-line or not.

    #22459
    Yutaka Emura
    Keymaster

    Hello Patrick,

    How did you select with stream selection mode? What was the macro code for it?

    #22460
    Patrick C
    Participant

    Hello Yutaka,

    Basically I selected with the keyboard (ctrl+F8 for line; shift + end + arrow right for stream)
    Written as macro code this would be:

    to select in line selection mode
    editor.ExecuteCommandByID(4154);

    To select in stream selection mode
    document.selection.StartOfLine(false,eeLineView | eeLineHomeText);
    document.selection.EndOfLine(true,eeLineView);
    document.selection.CharRight(true,1);

    Importance of virtual space
    I now noticed, that a visually (images of the first post #22457) identical selection made in stream selection mode is only different from line selection mode when virtual space is enabled.

    To me it will remain confusing, that BottomPointY – TopPointY covers n+1 lines when only n were selected with CommandID(4154). Nevertheless, I’ll be fine as long as I can count on this (n+1 lines) consistently being the case when the selection’s last character is a new-line character.

    Thanks!
    Patrick

    #22461
    Yutaka Emura
    Keymaster

    Hello Patrick,

    Yes, the Virtual Space mode makes a big difference. In other words, the cursor position is where BottomPointY is.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.