Skip to content

Add language keyword candidates to auto-completion#1070

Open
saberoueslati wants to merge 1 commit into
dail8859:masterfrom
saberoueslati:feature/839-keyword-autocomplete
Open

Add language keyword candidates to auto-completion#1070
saberoueslati wants to merge 1 commit into
dail8859:masterfrom
saberoueslati:feature/839-keyword-autocomplete

Conversation

@saberoueslati
Copy link
Copy Markdown
Contributor

Description

Fixes #839

NotepadNext's auto-completion only suggests words already present in the document. This PR adds language keyword candidates to the completion list so keywords appear as suggestions even before they have been typed in the file. The change is gated by the existing Auto Completion preference and requires no new settings.


Changes

src/ScintillaNext.h

  • Added #include <QStringList> and a public QStringList languageKeywords member to hold the active language's keyword list alongside the existing languageName and languageSingleLineComment fields.

src/scripts/init.lua

  • Added GetLanguageKeywords(languageName) helper that reads languages[languageName].keywords, splits each space-separated keyword string into individual tokens, deduplicates them, recurses into additionalLanguages (matching SetLanguage's behaviour), and returns a sorted array. Returns {} for languages with no keyword definitions (e.g. plain Text).

src/NotepadNextApplication.cpp

  • Added one line at the end of setEditorLanguage() — calls GetLanguageKeywords(languageName) through the Lua state and stores the result in editor->languageKeywords. The field is unconditionally reassigned on every language change, so switching to Text or any other keyword-less language clears it automatically.

src/decorators/AutoCompletion.cpp

  • Extended showAutoCompletion() to iterate editor->languageKeywords after the document scan, inserting any keyword that starts with the current prefix into the existing QSet<QByteArray> candidate set. Deduplication is handled for free by the set. The 3-character minimum, SCFIND_MATCHCASE case-sensitivity, SC_ORDER_PERFORMSORT ordering, and the single Editor/AutoCompletion preference toggle are all preserved.

Video of manual test below :

Screencast.from.2026-06-02.21-34-24.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-completion does not include keywords

1 participant