Menu

#2445 SCI_AUTOCSETDROPRESTOFWORD(true) + SCI_SETMULTIPASTE(SC_MULTIPASTE_EACH) dont work together

Bug
open
nobody
scintilla (610)
5
2024-07-12
2024-06-30
No

Setting SCI_AUTOCSETDROPRESTOFWORD(true) + SCI_SETMULTIPASTE(SC_MULTIPASTE_EACH) leads to bad autocomplete insertions. Here's how to reproduce it using SciTE source code:

  • In SciTEProps.cxx change wEditor.AutoCSetDropRestOfWord(false); to wEditor.AutoCSetDropRestOfWord(true);

With a new build do this:

  • Install and configure c.api as explained on https://github.com/moltenform/scite-files/blob/main/files/api_files_howto.md
  • In SciTEGlobal.properties set autocomplete.multi to 1
  • Start SciTE
  • Save an empty document as Test.c
  • Add two lines, first saying 'abcdef' and second saying 'abort'
  • Place the caret at the start of the second line
  • Press Ctrl+Space to activate autocomplete
  • Choose 'abort'
  • Notice how it now replaces part of the 'abcdef' on the first line and its newlines. On Windows it now will now say 'abcabortabort' as the only line.

I beleive the error to be in ScintillaBase::AutoCompleteInsert and specifically this bit:

if (positionInsert - removeLen >= 0) {
        positionInsert -= removeLen;
        pdoc->DeleteChars(positionInsert, removeLen);
}

In the example above positionInsert at the start of this snippet which is indeed the correct position to insert (8 on Windows). But then it subtracts removeLen (5) so that it finally deletes 5 characters starting at position 3 which is in the first line. Without the substraction it works as expected.

If SC_MULTIPASTE_EACH is off on then a different code path is used which does not to the substraction and it works fine.

If DropRestOfWord is off then removeLen equals 0 and it also works fine.

Discussion

  • Martijn Laan

    Martijn Laan - 2024-06-30

    Actually positionInsert is only the correct position to insert if the caret is at the start of the line. I'm not sure what the correct fix would be. I suppose the code should investigate the word each selection is on to be able to find the correct insertposition and removeLen.

     
  • Neil Hodgson

    Neil Hodgson - 2024-07-12

    This is referring to SCI_AUTOCSETMULTI(SC_MULTIAUTOC_EACH) instead of SCI_SETMULTIPASTE(SC_MULTIPASTE_EACH).

    The relevant change sets for this are [bd09a9] and [b8fc27].

     

    Related

    Commit: [b8fc27]
    Commit: [bd09a9]


Log in to post a comment.

MongoDB Logo MongoDB