Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
let previousInline = this.backwardTraverser.getPreviousInlineElement();
while (!this.backwardTraversingComplete) {
if (previousInline && previousInline.isTextualInlineElement()) {
let textContent = previousInline.getTextContent();
if (!this.inlineBeforeCursor) {
// Make sure the inline before cursor is a non-empty text inline
this.inlineBeforeCursor = previousInline;
}
// build the word before cursor if it is not built yet
if (!this.cachedWordBeforeCursor) {
// Match on the white space, the portion after space is on the index of 1 of the matched result
// (index at 0 is whole match result, index at 1 is the word)
let matches = matchWhiteSpaces(textContent);
if (matches && matches.length == 2) {
this.cachedWordBeforeCursor = matches[1];
// if this.cachedTextBeforeCursor is not null, what we get is just a portion of it, need to append this.cachedTextBeforeCursor
if (this.cachedTextBeforeCursor) {
this.cachedWordBeforeCursor =
this.cachedWordBeforeCursor + this.cachedTextBeforeCursor;
}
}
}
this.cachedTextBeforeCursor = !this.cachedTextBeforeCursor
? textContent
: textContent + this.cachedTextBeforeCursor;
if (!this.inlineElementsBeforeCursor) {
this.inlineElementsBeforeCursor = [previousInline];