Просмотр исходного кода

Add comment explaining the custom `insertMatch`

Shane Kilkelly 9 лет назад
Родитель
Сommit
08faa64b57

+ 9 - 0
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee

@@ -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