Add language keyword candidates to auto-completion
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 publicQStringList languageKeywordsmember to hold the active language's keyword list alongside the existinglanguageNameandlanguageSingleLineCommentfields.
src/scripts/init.lua
- Added
GetLanguageKeywords(languageName)helper that readslanguages[languageName].keywords, splits each space-separated keyword string into individual tokens, deduplicates them, recurses intoadditionalLanguages(matchingSetLanguage'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()— callsGetLanguageKeywords(languageName)through the Lua state and stores the result ineditor->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 iterateeditor->languageKeywordsafter the document scan, inserting any keyword that starts with the current prefix into the existingQSet<QByteArray>candidate set. Deduplication is handled for free by the set. The 3-character minimum,SCFIND_MATCHCASEcase-sensitivity,SC_ORDER_PERFORMSORTordering, and the singleEditor/AutoCompletionpreference toggle are all preserved.
Video of manual test below :
@dail8859 I'll take care of it, I'll ping you as soon as I'm finished with it.
@dail8859 I made the changes as you requested
Apologies for the delay. Thanks for the PR!