From 08faa64b57f28a7ec9ed2966247d957f743ec287 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 3 Jul 2017 15:20:36 +0100 Subject: [PATCH] Add comment explaining the custom `insertMatch` --- .../aceEditor/auto-complete/AutoCompleteManager.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee index 1669308762..9115cdcf5f 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee +++ b/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