Skip to content

Exception when simple symbol layout starts with a slash #2176

@eranl

Description

@eranl

My simple symbol layout happens to start with a slash, and that results in a stack trace on every keyboard load, due to

if (layoutFileContent.startsWith("[") || (LayoutUtilsCustom.isCustomLayout(layoutName) && layoutFileContent.startsWith("/"))) {
. Why is slash special-cased?

could not parse json layout for custom.8w1ed6gzek3., falling back to simple layout parsing (Explain with AI)
kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Expected start of the array '[', but had '/' instead at path: $
JSON input: /
...
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:587)
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:585)
at kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken(AbstractJsonLexer.kt:789)
at kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken(StringJsonLexer.kt:76)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure(StreamingJsonDecoder.kt:102)
at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:29)
at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
at kotlinx.serialization.json.Json.decodeFromString(Json.kt:149)
at helium314.keyboard.keyboard.internal.keyboard_parser.LayoutParser.parseJsonString(LayoutParser.kt:188)
at helium314.keyboard.keyboard.internal.keyboard_parser.LayoutParser.createCacheLambda(LayoutParser.kt:79)
at helium314.keyboard.keyboard.internal.keyboard_parser.LayoutParser.parseLayout(LayoutParser.kt:43)
at helium314.keyboard.keyboard.internal.keyboard_parser.KeyboardParser.addSymbolPopupKeys(KeyboardParser.kt:287)
at helium314.keyboard.keyboard.internal.keyboard_parser.KeyboardParser.createRows(KeyboardParser.kt:100)
at helium314.keyboard.keyboard.internal.keyboard_parser.KeyboardParser.parseLayout(KeyboardParser.kt:63)
at helium314.keyboard.keyboard.internal.KeyboardBuilder.load(KeyboardBuilder.kt:55)
at helium314.keyboard.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:174)
at helium314.keyboard.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:153)
at helium314.keyboard.keyboard.KeyboardSwitcher.setKeyboard(KeyboardSwitcher.java:210)
at helium314.keyboard.keyboard.KeyboardSwitcher.setAlphabetKeyboard(KeyboardSwitcher.java:256)
at helium314.keyboard.keyboard.internal.KeyboardState.setAlphabetKeyboard(KeyboardState.kt:246)
at helium314.keyboard.keyboard.internal.KeyboardState.onLoadKeyboard(KeyboardState.kt:109)
at helium314.keyboard.keyboard.KeyboardSwitcher.loadKeyboard(KeyboardSwitcher.java:165)
at helium314.keyboard.keyboard.KeyboardSwitcher.reloadMainKeyboard(KeyboardSwitcher.java:539)
at helium314.keyboard.latin.LatinIME.onStartInputViewInternal(LatinIME.java:948)
at helium314.keyboard.latin.LatinIME$UIHandler.onStartInputView(LatinIME.java:477)
at helium314.keyboard.latin.LatinIME.onStartInputView(LatinIME.java:775)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions