From 962762de719929970fa69c9b97dd9bd5d7ce6247 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 12 Sep 2019 06:02:39 +1000 Subject: [PATCH] [Developer] Prevent package metadata preprocessor from treating .model.js files as keyboard files when they don't exist. Fixes #2081. --- .../Keyman.System.PackageInfoRefreshKeyboards.pas | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/windows/src/global/delphi/packages/Keyman.System.PackageInfoRefreshKeyboards.pas b/windows/src/global/delphi/packages/Keyman.System.PackageInfoRefreshKeyboards.pas index d21e7cd245..8699449c36 100644 --- a/windows/src/global/delphi/packages/Keyman.System.PackageInfoRefreshKeyboards.pas +++ b/windows/src/global/delphi/packages/Keyman.System.PackageInfoRefreshKeyboards.pas @@ -25,6 +25,7 @@ type function IsKeyboardFileByContent(f: TPackageContentFile): Boolean; function CheckKeyboardLanguages: Boolean; function CheckKeyboardTargetVersions: Boolean; + function IsModelFileByName(f: TPackageContentFile): Boolean; public type TPackageKeyboardInfo = record Name, ID, Version: string; @@ -222,6 +223,11 @@ begin end; end; +function TPackageInfoRefreshKeyboards.IsModelFileByName(f: TPackageContentFile): Boolean; +begin + Result := TRegEx.IsMatch(f.FileName, '\.model\.js$', [roIgnoreCase]); +end; + function TPackageInfoRefreshKeyboards.IsKeyboardFileByName(f: TPackageContentFile): TKMFileType; begin if f.FileType = ftKeymanFile then @@ -232,6 +238,12 @@ begin if f.FileType <> ftJavascript then Exit(ftOther); + // A lexical model file will typicaly have the extension .model.js. This prevents the + // package editor from treating a lexical model as a keyboard when refreshing the list + // of included keyboards + if IsModelFileByName(f) then + Exit(ftOther); + // Need to test if the JS is a valid keyboard file. // This is a bit of a pain... but we have to stick with .js for compat if not FileExists(f.FileName) or IsKeyboardFileByContent(f) then