Add comment explaining the custom insertMatch

This commit is contained in:
Shane Kilkelly 2017-07-03 15:20:36 +01:00
parent 96d269e348
commit 08faa64b57

View file

@ -155,6 +155,15 @@ define [
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
editor.session.remove(range)
# Provide our own `insertMatch` implementation.
# See the `insertMatch` method of Autocomplete in `ext-language_tools.js`.
# We need this to account for editing existing commands, particularly when
# adding a prefix.
# We fix this by detecting when the cursor is in the middle of an existing
# command, and adjusting the insertions/deletions accordingly.
# Example:
# when changing `\ref{}` to `\href{}`, ace default behaviour
# is likely to end up with `\href{}ref{}`
if !data?
completions = this.completions
popup = editor.completer.popup