Merge pull request #342 from Kellenok/main
Escaped brackets and comma double avoidance
This commit is contained in:
@@ -611,24 +611,28 @@ export class TextAreaAutoComplete {
|
||||
const item = $el(
|
||||
"div.pysssss-autocomplete-item",
|
||||
{
|
||||
onclick: () => {
|
||||
this.el.focus();
|
||||
let value = wordInfo.value ?? wordInfo.text;
|
||||
const use_replacer = wordInfo.use_replacer ?? true;
|
||||
if (TextAreaAutoComplete.replacer && use_replacer) {
|
||||
value = TextAreaAutoComplete.replacer(value);
|
||||
}
|
||||
this.helper.insertAtCursor(value + this.separator, -before.length, wordInfo.caretOffset);
|
||||
setTimeout(() => {
|
||||
this.#update();
|
||||
}, 150);
|
||||
},
|
||||
onmousemove: () => {
|
||||
this.#setSelected(wordInfo);
|
||||
},
|
||||
onclick: () => {
|
||||
this.el.focus();
|
||||
let value = wordInfo.value ?? wordInfo.text;
|
||||
const use_replacer = wordInfo.use_replacer ?? true;
|
||||
if (TextAreaAutoComplete.replacer && use_replacer) {
|
||||
value = TextAreaAutoComplete.replacer(value);
|
||||
}
|
||||
value = this.#escapeParentheses(value);
|
||||
const afterCursor = this.helper.getAfterCursor();
|
||||
const shouldAddSeparator = !afterCursor.trim().startsWith(this.separator.trim());
|
||||
this.helper.insertAtCursor(
|
||||
value + (shouldAddSeparator ? this.separator : ''),
|
||||
-before.length,
|
||||
wordInfo.caretOffset
|
||||
);
|
||||
setTimeout(() => {
|
||||
this.#update();
|
||||
}, 150);
|
||||
},
|
||||
},
|
||||
parts
|
||||
);
|
||||
);
|
||||
|
||||
if (wordInfo === this.selected) {
|
||||
hasSelected = true;
|
||||
@@ -653,6 +657,10 @@ export class TextAreaAutoComplete {
|
||||
this.dropdown.style.maxHeight = (window.innerHeight - position.top) + "px";
|
||||
}
|
||||
|
||||
#escapeParentheses(text) {
|
||||
return text.replace(/\(/g, '\\(').replace(/\)/g, '\\)');
|
||||
}
|
||||
|
||||
#hide() {
|
||||
this.selected = null;
|
||||
this.dropdown.remove();
|
||||
|
||||
Reference in New Issue
Block a user