Menu

#2391 Move SetCandidateWindowPos() out of if (imeEndToImeCaretU16 != 0) block.

Bug
closed
5
2023-07-26
2023-06-23
johnsonj
No
    if (imeEndToImeCaretU16 != 0) {
        // Move back IME caret from current last position to imeCaretPos.
        const Sci::Position currentPos = CurrentPosition();
        const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(currentPos, imeEndToImeCaretU16);

        MoveImeCarets(-currentPos + imeCaretPosDoc);

        if (std::find(imeIndicator.begin(), imeIndicator.end(), IndicatorTarget) != imeIndicator.end()) {
            // set candidate window left aligned to beginning of target string.
            SetCandidateWindowPos();
        }
    }

    What does imeEndToImeCaretU16 relates with SetCandidateWindowPos()?
    What guarantees there is no target input  if (imeEndToImeCaretU16 != 0)?
    Move  SetCandidateWindowPos() out of if (imeEndToImeCaretU16 != 0) block.

Related discussion:
https://sourceforge.net/p/scintilla/bugs/2390/?limit=25#8af1
https://sourceforge.net/p/scintilla/feature-requests/1304/

1 Attachments

Discussion

  • Zufu Liu

    Zufu Liu - 2023-06-25
     

    Related

    Feature Requests: #1300

    • johnsonj

      johnsonj - 2023-06-27

      The above link has no discussion why 2nd SetCandidateWindowPos() should be inside "if (imeEndToImeCaretU16 != 0) block".

       
      • Zufu Liu

        Zufu Liu - 2023-06-27

        Because otherwise the caret is not moved?
        seems the correct code to align candidate window with target string is finding offset between ime.GetImeCaretPos() and target start (first IndicatorTarget in imeIndicator) .

         
        • johnsonj

          johnsonj - 2023-06-27

          Candidate window should be located at ime caret.
          2nd SetCandidateWindowPos follows ime caret.
          You should not try to control the ime caret.
          It breaks scintilla ime from syncronizing with the internal state of IMM32.

          I have had a hard time catching up with the recent bugs with TSF.
          On the while, I managed to figure out what the purpose of 3 if checks is.
          I wll continue on reverting the rest if (!onlyTarget) block with causes.

           
  • johnsonj

    johnsonj - 2023-06-27

    Now 2nd SetCandidateWindowPos() moves ut of "if check"
    Let us take a close look at "if check" inside.

    What if imeEndToImeCaretU16 is 0 ?
    Then pdoc->GetRelativePositionUTF16(currentPos, 0);
    So currentPos equals to imeCaretPosDoc
    And then MoveImeCarets(0);
    There is no moving, just addition and subtraction!.

    In addition,
    Within void ScintillaWin::MoveImeCarets(Sci::Position offset)
    if offset is 0, then there is still no caret moving.

    I do not check if offset is 0.
    since benifits of speed is negligible.

    And
    I think readabilty is more important rather than efficency for IO-bound functon.

    "if (imeEndToImeCaretU16 != 0) check" compromises readibility.
    so It is reasonable it should be removed.

     
  • Neil Hodgson

    Neil Hodgson - 2023-07-04
    • Priority: 1 --> 5
     
  • Neil Hodgson

    Neil Hodgson - 2023-07-04

    Superseded by [feature-requests:#1488] which completely removes the second SetCandidateWindowPos in HandleCompositionInline.

     

    Related

    Feature Requests: #1488

    • johnsonj

      johnsonj - 2023-07-05

      Candidate window position gets now related with user's preference.
      I feel it looks not bad visually while playing with japannes input.
      In addition, less code feels me comfortable.

       
  • Neil Hodgson

    Neil Hodgson - 2023-07-26
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB