Menu

#2307 No autocomplete display if last character of the document

Bug
closed-fixed
nobody
5
2022-02-09
2022-01-11
No

Tested with SciTE on Platform Windows 7 SP1.

SciTE v5.1.16 will not display autocomplete with a line that is not followed by an existing character or a newline sequence.

A test case used is same as [#2265] with test.lua.

With an empty test.lua file, type o and the autocomplete will not display. Undo, and type a space, type home key to go back to position 0 and then type o which will now display the autocomplete.

I tested SC1.exe from v5.0.2 to v5.1.16. All versions up to v5.1.15 works as expected to invoke the display of the autocomplete. So, some code changed after release of v5.1.15 which changed the autocomplete behaviour for the release of v5.1.16.

I have looked at some bug fixes in the timeframe just before release of v5.1.16:

  • [#2294] SCI_AUTOCSHOW crashes on empty itemList with SC_ORDER_CUSTOM (Windows)
    • I commented the code additions of the commit, recompiled and autocomplete issue remains.
  • [#2296] Autocompletion not working on wayland
    • GTK so cannot affect Sc1.

No luck with my discovering the cause. The commit log of /src/AutoComplete.cxx gives me no clues so some other code may have caused this. Hope you can solve this.

Related

Bugs: #2265
Bugs: #2294
Bugs: #2296

Discussion

  • Neil Hodgson

    Neil Hodgson - 2022-01-12
    • labels: scite scintilla --> scite, scintilla
    • status: open --> open-accepted
     
  • Neil Hodgson

    Neil Hodgson - 2022-01-12

    Reproduced the problem with current code.

     
  • Michael Heath

    Michael Heath - 2022-01-15

    I incremently patched sources of v5.1.15 and recompiled until the issue occured. This patch is the cause [483efd].

    I have tested with printf in bool SciTEBase::StartAutoComplete() function and with starting v5.1.15, I get "o" from printf("line: \"%s\"\n", line.c_str());. The patched v5.1.15 gives "".

    This means GetCurrentLine() has an issue. So, this quote comes to mind:

    Applications should allocate a buffer 1 more than this to accommodate the NUL.

    Higher up in SciTEBase.cxx is:

    std::string SciTEBase::GetCurrentLine() {
        // Get needed buffer size
        const SA::Position len = wEditor.GetCurLine(0, nullptr);
        // Allocate buffer, including space for NUL
        std::string text(len, '\0');
        // And get the line
        wEditor.GetCurLine(len, &text[0]);
        // Return without extra NUL
        return text.substr(0, text.length()-1);
    }
    

    which I changed to

    std::string SciTEBase::GetCurrentLine() {
        // Get needed buffer size
        const SA::Position len = wEditor.GetCurLine(0, nullptr);
        // Allocate buffer, including space for NUL
        std::string text(len + 1, '\0');
        // And get the line
        wEditor.GetCurLine(len, &text[0]);
        // Return without extra NUL
        return text.substr(0, text.length()-1);
    }
    

    which just adds + 1 to len, recompiled and autocomplete displays now.

    I do not know if this is correct fix or not. Seems that [483efd] may cause more issues with get text type functions which I may not be aware of yet.

    Just thought I would give a heads up to my investigation to gather some more experience.

     

    Related

    Commit: [483efd]

  • Neil Hodgson

    Neil Hodgson - 2022-01-17
    • labels: scite, scintilla --> scite, scintilla, autocomplete
    • status: open-accepted --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2022-01-17

    The length is accurate now so there is no need to chop off the end. Committed [fd34e2].

     

    Related

    Commit: [fd34e2]

  • Neil Hodgson

    Neil Hodgson - 2022-02-09
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB