Skip to content

Commit

Permalink
Merge pull request #42 from argenos/feat/autosuggest-more-situational…
Browse files Browse the repository at this point in the history
…ly-aware

Don't trigger autosuggest if preceding char is [a-zA-Z0-9]
  • Loading branch information
argenos authored Jul 19, 2021
2 parents 2995181 + 5b2860f commit 51c0e35
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/suggest/codemirror-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ function checkForInputPhrase(
line: pos.line,
ch: pos.ch - phrase.length,
};
return cmEditor.getRange(from, pos) === phrase;

if (cmEditor.getRange(from, pos) !== phrase) {
return false;
}

const precedingChar = cmEditor.getRange(
{
line: pos.line,
ch: from.ch - 1,
},
from
);
return !precedingChar || /[^`a-zA-Z0-9]/.test(precedingChar);
}

function isCursorBeforePos(
Expand Down

0 comments on commit 51c0e35

Please sign in to comment.