mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 22:59:01 +02:00
Add a skeleton of a custom insertMatch function
This commit is contained in:
+20
@@ -5,6 +5,7 @@ define [
|
||||
"ace/ext-language_tools"
|
||||
], (SuggestionManager, SnippetManager) ->
|
||||
Range = ace.require("ace/range").Range
|
||||
aceSnippetManager = ace.require('ace/snippets').snippetManager
|
||||
|
||||
getLastCommandFragment = (lineUpToCursor) ->
|
||||
if m = lineUpToCursor.match(/(\\[^\\]+)$/)
|
||||
@@ -154,6 +155,25 @@ define [
|
||||
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
||||
editor.session.remove(range)
|
||||
|
||||
if !data?
|
||||
completions = this.completions
|
||||
popup = editor.completer.popup
|
||||
data = popup.getData(popup.getRow())
|
||||
data.completer =
|
||||
insertMatch: (editor, matchData) ->
|
||||
console.log ">> custom insertMatch"
|
||||
console.log ">> data", data
|
||||
ranges = editor.selection.getAllRanges()
|
||||
for range in ranges
|
||||
range.start.column -= completions.filterText.length;
|
||||
editor.session.remove(range);
|
||||
if matchData.snippet
|
||||
console.log ">> snippet"
|
||||
aceSnippetManager.insertSnippet(editor, matchData.snippet);
|
||||
else
|
||||
console.log ">> string", matchData
|
||||
editor.execCommand("insertstring", matchData.value || matchData);
|
||||
|
||||
Autocomplete::_insertMatch.call this, data
|
||||
|
||||
# Overwrite this to set autoInsert = false and set font size
|
||||
|
||||
Reference in New Issue
Block a user