mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-28 11:17:45 +00:00
feat(developer): fix vars and markers 🙀
- Figured it out. Problem was a custom Array constructor. - also updated ElementString class, which would have the same issue. For: #9121 For: #9119
This commit is contained in:
parent
450e29cf2a
commit
12bb554b5a
3 changed files with 16 additions and 14 deletions
|
|
@ -31,11 +31,11 @@ export class ElementString extends Array<ElemElement> {
|
|||
* @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
|
||||
* If it is a string, will be interpreted per reorder element rules.
|
||||
*/
|
||||
constructor(sections: DependencySections, source: string | string[], order?: string, tertiary?: string, tertiary_base?: string, prebase?: string) {
|
||||
super();
|
||||
//TODO-LDML: full UnicodeSet and parsing
|
||||
static fromStrings(sections: DependencySections, source: string | string[], order?: string, tertiary?: string, tertiary_base?: string, prebase?: string) : ElementString {
|
||||
// the returned array
|
||||
const array = new ElementString();
|
||||
if(!source) {
|
||||
return;
|
||||
return array;
|
||||
}
|
||||
|
||||
let items : ElementSegment[];
|
||||
|
|
@ -104,8 +104,9 @@ export class ElementString extends Array<ElemElement> {
|
|||
(ElemElementFlags.type & typeFlag) |
|
||||
(tertiary_bases?.[i] == '1' /* TODO-LDML: or 'true'? */ ? ElemElementFlags.tertiary_base : 0) |
|
||||
(prebases?.[i] == '1' /* TODO-LDML: or 'true'? */ ? ElemElementFlags.prebase : 0);
|
||||
this.push(elem);
|
||||
array.push(elem);
|
||||
};
|
||||
return array;
|
||||
}
|
||||
isEqual(a: ElementString): boolean {
|
||||
if (a.length != this.length) {
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ export class Elem extends Section {
|
|||
strings: ElementString[] = [];
|
||||
constructor(sections: DependencySections) {
|
||||
super();
|
||||
this.strings.push(new ElementString(sections, '')); // C7043: null element string
|
||||
this.strings.push(ElementString.fromStrings(sections, '')); // C7043: null element string
|
||||
}
|
||||
/**
|
||||
* @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
|
||||
* If it is a string, will be interpreted per reorder element ruls.
|
||||
*/
|
||||
allocElementString(sections: DependencySections, source: string | string[], order?: string, tertiary?: string, tertiary_base?: string, prebase?: string): ElementString {
|
||||
let s = new ElementString(sections, source, order, tertiary, tertiary_base, prebase);
|
||||
let s = ElementString.fromStrings(sections, source, order, tertiary, tertiary_base, prebase);
|
||||
let result = this.strings.find(item => item.isEqual(s));
|
||||
if(result === undefined) {
|
||||
result = s;
|
||||
|
|
@ -547,14 +547,14 @@ export class List extends Section {
|
|||
let result = this.lists.find(item => item.isEqual(s));
|
||||
if(result === undefined) {
|
||||
// allocate a new ListItem
|
||||
result = new ListItem(s, opts, sections);
|
||||
result = ListItem.fromStrings(s, opts, sections);
|
||||
this.lists.push(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
constructor(strs: Strs) {
|
||||
super();
|
||||
this.lists.push(new ListItem([], {}, { strs })); // C7043: null element string
|
||||
this.lists.push(ListItem.fromStrings([], {}, { strs })); // C7043: null element string
|
||||
}
|
||||
lists: ListItem[] = [];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,15 +33,16 @@ export class ListItem extends Array<ListIndex> implements OrderedStringList {
|
|||
* be needed depending on the options
|
||||
* @returns
|
||||
*/
|
||||
constructor(source: Array<string>, opts: StrsOptions, sections: DependencySections) {
|
||||
super();
|
||||
if(!source) {
|
||||
return;
|
||||
static fromStrings(source: Array<string>, opts: StrsOptions, sections: DependencySections) : ListItem {
|
||||
const a = new ListItem();
|
||||
if (!source) {
|
||||
return a;
|
||||
}
|
||||
for (const str of source) {
|
||||
let index = new ListIndex(sections.strs.allocString(str, opts, sections));
|
||||
this.push(index);
|
||||
a.push(index);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
getItemOrder(item: string): number {
|
||||
return this.findIndex(({value}) => value.value === item);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue