mirror of
https://github.com/stracker-phil/obsidian-mention-things.git
synced 2026-07-22 05:43:27 +00:00
fix: do not suggest on emails etc
This commit is contained in:
parent
a68e74a863
commit
eeed66a954
1 changed files with 11 additions and 1 deletions
12
main.js
12
main.js
|
|
@ -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 },
|
||||
|
|
|
|||
Loading…
Reference in a new issue