Add language keyword candidates to auto-completion#1070
Open
saberoueslati wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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#include <QStringList>and a publicQStringList languageKeywordsmember to hold the active language's keyword list alongside the existinglanguageNameandlanguageSingleLineCommentfields.src/scripts/init.luaGetLanguageKeywords(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.cppsetEditorLanguage()— 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.cppshowAutoCompletion()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 :
Screencast.from.2026-06-02.21-34-24.webm