mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #1872 from overleaf/hb-autocomplete-braces
Autocomplete braces bugfixes GitOrigin-RevId: 9b3af30b71b85cf95288b0388c9af7792b87ca80
This commit is contained in:
committed by
sharelatex
parent
350e2ac38f
commit
1e14f75e08
+3
-3
@@ -274,21 +274,21 @@ define([
|
||||
monkeyPatchAutocomplete() {
|
||||
const { Autocomplete } = ace.require('ace/autocomplete')
|
||||
const Util = ace.require('ace/autocomplete/util')
|
||||
const { editor } = this
|
||||
|
||||
if (Autocomplete.prototype._insertMatch == null) {
|
||||
// Only override this once since it's global but we may create multiple
|
||||
// autocomplete handlers
|
||||
Autocomplete.prototype._insertMatch = Autocomplete.prototype.insertMatch
|
||||
Autocomplete.prototype.insertMatch = function(data) {
|
||||
const { editor } = this
|
||||
|
||||
const pos = editor.getCursorPosition()
|
||||
let range = new Range(pos.row, pos.column, pos.row, pos.column + 1)
|
||||
const nextChar = editor.session.getTextRange(range)
|
||||
|
||||
// If we are in \begin{it|}, then we need to remove the trailing }
|
||||
// since it will be adding in with the autocomplete of \begin{item}...
|
||||
if (
|
||||
/^\\\w+(\[[\w\\,= ]*\])?{/.test(this.completions.filterText) &&
|
||||
/^\\\w+(\[[\w\\,=. ]*\])?{/.test(this.completions.filterText) &&
|
||||
nextChar === '}'
|
||||
) {
|
||||
editor.session.remove(range)
|
||||
|
||||
Reference in New Issue
Block a user