fix: exclude Meta, Alt, Home and End key press for autocomplete trigger (#3441)

This commit is contained in:
lohit 2024-11-20 03:31:44 +05:30 committed by GitHub
parent 7fd7eafdcb
commit c4492b5d94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -281,9 +281,9 @@ export default class CodeEditor extends React.Component {
while (end < currentLine.length && /[^{}();\s\[\]\,]/.test(currentLine.charAt(end))) ++end; while (end < currentLine.length && /[^{}();\s\[\]\,]/.test(currentLine.charAt(end))) ++end;
while (start && /[^{}();\s\[\]\,]/.test(currentLine.charAt(start - 1))) --start; while (start && /[^{}();\s\[\]\,]/.test(currentLine.charAt(start - 1))) --start;
let curWord = start != end && currentLine.slice(start, end); let curWord = start != end && currentLine.slice(start, end);
//Qualify if autocomplete will be shown // Qualify if autocomplete will be shown
if ( if (
/^(?!Shift|Tab|Enter|Escape|ArrowUp|ArrowDown|ArrowLeft|ArrowRight|\s)\w*/.test(event.key) && /^(?!Shift|Tab|Enter|Escape|ArrowUp|ArrowDown|ArrowLeft|ArrowRight|Meta|Alt|Home|End\s)\w*/.test(event.key) &&
curWord.length > 0 && curWord.length > 0 &&
!/\/\/|\/\*|.*{{|`[^$]*{|`[^{]*$/.test(currentLine.slice(0, end)) && !/\/\/|\/\*|.*{{|`[^$]*{|`[^{]*$/.test(currentLine.slice(0, end)) &&
/(?<!\d)[a-zA-Z\._]$/.test(curWord) /(?<!\d)[a-zA-Z\._]$/.test(curWord)