From ed490fcbeffa12ecbd9dc7fdd7a42e35e5d6c720 Mon Sep 17 00:00:00 2001 From: jahorton Date: Thu, 29 Jul 2021 09:41:34 +0700 Subject: [PATCH] refactor(common/core/web): relocates empty-row fix to keyboard-processor module --- .../src/keyboards/activeLayout.ts | 30 +++++++++++++++++++ web/source/osk/oskLayerGroup.ts | 16 ---------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts b/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts index eb997366f2..da65c4aad2 100644 --- a/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts +++ b/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts @@ -635,6 +635,35 @@ namespace com.keyman.keyboards { return this.layerMap[layerId]; } + /** + * Refer to https://github.com/keymanapp/keyman/issues/254, which mentions + * KD-11 from a prior issue-tracking system from the closed-source days that + * resulted in an unintended extra empty row. + * + * It'll be pretty rare to see a keyboard affected by the bug, but we don't + * 100% control all keyboards out there, so it's best we make sure the edge + * case is covered. + * + * @param layers The layer group to be loaded for the form factor. Will be + * mutated by this operation. + */ + static correctLayerEmptyRowBug(layers: LayoutLayer[]) { + for(let n=0; n0; i--) { + if(rows[i-1]['key'].length > 0) { + break; + } + } + + if(i < rows.length) { + rows.splice(i-rows.length,rows.length-i); + } + } + } + /** * * @param layout @@ -651,6 +680,7 @@ namespace com.keyman.keyboards { let layerMap: {[layerId: string]: ActiveLayer} = {}; var rows: LayoutRow[]; + ActiveLayout.correctLayerEmptyRowBug(layout['layer']); layers=layout['layer']; // ***Delete any empty rows at the end added by compiler bug... diff --git a/web/source/osk/oskLayerGroup.ts b/web/source/osk/oskLayerGroup.ts index 2a959868c4..f405401d56 100644 --- a/web/source/osk/oskLayerGroup.ts +++ b/web/source/osk/oskLayerGroup.ts @@ -40,22 +40,6 @@ namespace com.keyman.osk { var tKey=vkbd.getDefaultKeyObject(); tKey['fontsize']=ls.fontSize; - // ***Delete any empty rows at the end added by compiler bug... - for(n=0; n0; i--) { - if(rows[i-1]['key'].length > 0) { - break; - } - } - - if(i < rows.length) { - rows.splice(i-rows.length,rows.length-i); - } - } - // ...remove to here when compiler bug fixed *** - // Set the OSK row height, **assuming all layers have the same number of rows** // Get the actual available document width and scale factor according to device type