If() and set() don't work on Windows but work on Web

Here’s a minimal keyboard test case that works on the web browser as expected but not in the Windows KeyMan app:

store(&NAME) 'test'
store(&TARGETS) 'any windows macosx linux web iphone ipad androidphone androidtablet mobile desktop tablet'
store(smallCapsOn) '0'

store(SmallCapsRef) "abcdefghijklmnoprstuvwy"
store(SmallCaps) U+1D00 U+0299 U+1D04 U+1D05 U+1D07 U+A730 U+0262 U+029C U+026A U+1D0A U+1D0B U+029F U+1D0D U+0274 U+1D0F U+1D18 U+0280 U+A731 U+1D1B U+1D1C U+1D20 U+1D21 U+26A U+1D0A U+1D0B U+029F U+1D0D U+0274 U+1D0F U+1D18  U+1D1A U+0280 U+A731 U+1D1B U+1D1C U+1D20 U+1D21 U+028F

begin Unicode > use(main)

group(main) using keys

if(smallCapsOn='1') '^' + any(SmallCapsRef) > index(SmallCaps,3) '^'
if(smallCapsOn='1') '^=' + '=' > nul set(smallCapsOn='0')
if(smallCapsOn!='1') '=' + '=' > '^' set(smallCapsOn='1')

c Test. Type aaa==aaa==aaa==aaa aaa==
c Should end up with: aaaᴀᴀᴀaaaᴀᴀᴀ aaa^
c Works on Web tester but not on Windows 15.0.268

It’s supposed to trigger a kind of ‘small caps’ mode with a double press of = key and then turn it off with the same, but while the rule if(smallCapsOn) gets triggered, the set(smallCapsOn) doesn’t happen. Everything works as intended on the web version which is why I think there may be a bug or else something I’m overlooking.

I found this potentially relevant issue: bug(developer): compiler generates invalid javascript for unquoted numbers in `if()` statements · Issue #7005 · keymanapp/keyman · GitHub but it’s not obviously related.

@ross are you able to look at this with @rowbory?

Any help gratefully received. And let me know if you can’t reproduce it.
I was thinking I could try older versions of Keyman and the Mac version to see how it behaves.

I made a keyboard project based on your .kmn file above.
xyz.zip (4.5 KB)

When I test in the Keyman Developer web tester with the sequence you list
aaa==aaa==aaa==aaa aaa==
I get
aaaᴀᴀᴀaaaᴀᴀᴀ^ aaa==
and it seems at that point that the smallCapsOn flag is set, but the rules don’t produce small caps because there’s a space after the ^.

But I can confirm that when I install the same keyboard in Windows and type aaa== I get aaa^ but typing a after that produces a not ᴀ as expected.

I reduced the relevant lines to this: (eliminating spaces which I didn’t think would interfere with anything)

if(smallCapsOn='1')+any(SmallCapsRef)> index(SmallCaps,2)
if(smallCapsOn='1')'='+'='> nul set(smallCapsOn='0')
if(smallCapsOn!='1')'='+'='> nul set(smallCapsOn='1')

But still the smallcaps behaviour works in Web but not in Windows Keyman.

test.kmx.zip (801 Bytes)

I had inserted the ^ so that I could see more obviously what it thought was going on. But it wasn’t necessary.

Another smaller test case:

store(&NAME) 'test'
store(&TARGETS) 'any windows macosx linux web iphone ipad androidphone androidtablet mobile desktop tablet'
store(bFlag) '0'
begin Unicode > use(main)

group(main) using keys

if(bFlag='1')+'z'> '***'
if(bFlag!='1')'='+'='> set(bFlag='1') beep
c Test. Type: a==z==a==z
c Should get: a***==a==***
c Does that on Web tester but on Windows 15.0.268 gives: azaz (with 2 beeps when == typed)

I can reproduce this here, yes. It looks like this is a bug in the Keyman Core for Windows integration that we added in Keyman 15. @ross (our Windows dev) is away this week but will take a look next week when he returns. (I would take a look but currently in Germany working on another project so won’t have an opportunity until I return to Australia in a week and a half.)

1 Like

Absolutely no hurry from my side, but this seems bound to break other keyboards. Thanks for looking at it. Works perfectly in Mac Keyman.

1 Like

Ok @rowbory Thanks for the excellent details in reporting the bug. I will look into this next week.

Here is the issue create for this on git hub Issue #7074

There is a fix in Review here #7077

1 Like

@rowbory Keyman for windows 15.0.269 has the fix for the issue you reported. Thank you again for the report.

Thanks for the quick work. It seems to work fine now, though I seem to be hitting quite a different problem (keyboard not working when English is selected as the language) that I’ll write in another thread.