Skip to content

Commit

Permalink
fix: do not suggest on emails etc
Browse files Browse the repository at this point in the history
  • Loading branch information
saibotsivad committed Aug 20, 2023
1 parent a68e74a commit eeed66a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,20 @@ class AtPeopleSuggestor extends EditorSuggest {
this.peopleFileMap = peopleFileMap
}
onTrigger(cursor, editor, tFile) {
console.log('----editor', editor)
let charsLeftOfCursor = editor.getLine(cursor.line).substring(0, cursor.ch)
let atIndex = charsLeftOfCursor.lastIndexOf('@')
let query = atIndex >= 0 && charsLeftOfCursor.substring(atIndex + 1)
if (query && !query.includes(']]')) {
if (
query
&& !query.includes(']]')
&& (
// if it's an @ at the start of a line
atIndex === 0
// or if there's a space character before it
|| charsLeftOfCursor[atIndex - 1] === ' '
)
) {
return {
start: { line: cursor.line, ch: atIndex },
end: { line: cursor.line, ch: cursor.ch },
Expand Down

0 comments on commit eeed66a

Please sign in to comment.