--- a/src/eric7/QScintilla/APIsManager.py Tue Sep 27 14:58:59 2022 +0200 +++ b/src/eric7/QScintilla/APIsManager.py Tue Sep 27 14:59:32 2022 +0200 @@ -7,10 +7,11 @@ Module implementing the APIsManager. """ +import glob import os import pathlib -from PyQt6.QtCore import QDir, pyqtSignal, QObject +from PyQt6.QtCore import pyqtSignal, QLibraryInfo, QObject from PyQt6.Qsci import QsciAPIs from . import Lexers @@ -194,23 +195,29 @@ @return list of installed API files (list of strings) """ if self.__apis is not None: - if Globals.isWindowsPlatform(): - qsciPath = os.path.join(Globals.getPyQt6ModulesDirectory(), "qsci") - if os.path.exists(qsciPath): - # it's the installer - if self.__lexer.lexerName() is not None: - apidir = os.path.join(qsciPath, "api", self.__lexer.lexerName()) - fnames = [] - filist = QDir(apidir).entryInfoList( - ["*.api"], QDir.Filter.Files, QDir.SortFlag.IgnoreCase + qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath) + apisDir = os.path.join(qtDataDir, "qsci", "api") + if os.path.exists(apisDir): + if self.__lexer.language(): + apiDir = os.path.join(apisDir, self.__lexer.language()) + if not os.path.exists(apiDir): + # use lower case language + apiDir = os.path.join(apisDir, self.__lexer.language().lower()) + fnames = { + os.path.join(apiDir, f) + for f in glob.glob("*.api", root_dir=apiDir) + } + # combine with the QScintilla standard behavior + fnames |= { + os.path.join(apiDir, f) + for f in glob.glob( + "*.api", + root_dir=os.path.join(apisDir, self.__lexer.lexer()), ) - for fi in filist: - fnames.append(fi.absoluteFilePath()) - return fnames - else: - return [] - - return self.__apis.installedAPIFiles() + } + return sorted(fnames) + else: + return [] else: return []