livebook/assets/js/highlight/text_utils.js
Jonatan Kłosko acd100f3d3
Improve intellisense to handle structs and sigils (#513)
* Update Code.Fragment backport

* Support structs completion and show module subtype

* Support sigil completion

* Update changelog

* Don't show completion items for hidden modules

* Update Code.Fragment backport
2021-08-23 10:42:18 +02:00

13 lines
301 B
JavaScript

/**
* Returns length of suffix in `string` that should be replaced
* with `newSuffix` to avoid duplication.
*/
export function replacedSuffixLength(string, newSuffix) {
let suffix = newSuffix;
while (!string.endsWith(suffix)) {
suffix = suffix.slice(0, -1);
}
return suffix.length;
}