mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fix a few issues with ace autocomplete and cursors
This commit is contained in:
parent
beae4f2424
commit
b51af73516
5 changed files with 24 additions and 16 deletions
|
@ -9,7 +9,7 @@ define [
|
||||||
last_updated: null
|
last_updated: null
|
||||||
open_doc_id: null
|
open_doc_id: null
|
||||||
opening: true
|
opening: true
|
||||||
cursorPosition: null
|
cursorPosition: {}
|
||||||
gotoLine: null
|
gotoLine: null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,19 +29,23 @@ define [
|
||||||
constructor: (@$scope, @editor) ->
|
constructor: (@$scope, @editor) ->
|
||||||
@suggestionManager = new SuggestionManager()
|
@suggestionManager = new SuggestionManager()
|
||||||
|
|
||||||
insertMatch = Autocomplete::insertMatch
|
if !Autocomplete::_insertMatch?
|
||||||
editor = @editor
|
# Only override this once since it's global but we may create multiple
|
||||||
Autocomplete::insertMatch = (data) ->
|
# autocomplete handlers
|
||||||
pos = editor.getCursorPosition()
|
Autocomplete::_insertMatch = Autocomplete::insertMatch
|
||||||
range = new Range(pos.row, pos.column, pos.row, pos.column + 1)
|
Autocomplete::insertMatch = (data) ->
|
||||||
nextChar = editor.session.getTextRange(range)
|
pos = editor.getCursorPosition()
|
||||||
|
range = new Range(pos.row, pos.column, pos.row, pos.column + 1)
|
||||||
|
nextChar = editor.session.getTextRange(range)
|
||||||
|
|
||||||
# If we are in \begin{it|}, then we need to remove the trailing }
|
console.log "INSERT MATCH", this
|
||||||
# since it will be adding in with the autocomplete of \begin{item}...
|
|
||||||
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
# If we are in \begin{it|}, then we need to remove the trailing }
|
||||||
editor.session.remove(range)
|
# since it will be adding in with the autocomplete of \begin{item}...
|
||||||
|
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
||||||
insertMatch.call editor.completer, data
|
editor.session.remove(range)
|
||||||
|
|
||||||
|
Autocomplete::_insertMatch.call this, data
|
||||||
|
|
||||||
@$scope.$watch "autoComplete", (autocomplete) =>
|
@$scope.$watch "autoComplete", (autocomplete) =>
|
||||||
console.log "autocomplete change", autocomplete
|
console.log "autocomplete change", autocomplete
|
||||||
|
|
|
@ -13,9 +13,9 @@ define [], () ->
|
||||||
|
|
||||||
@editor.on "changeSelection", () =>
|
@editor.on "changeSelection", () =>
|
||||||
cursor = @editor.getCursorPosition()
|
cursor = @editor.getCursorPosition()
|
||||||
console.log "Updating cursor position", cursor
|
|
||||||
@$scope.$apply () =>
|
@$scope.$apply () =>
|
||||||
@$scope.cursorPosition = cursor
|
if @$scope.cursorPosition?
|
||||||
|
@$scope.cursorPosition = cursor
|
||||||
|
|
||||||
@$scope.$watch "gotoLine", (value) =>
|
@$scope.$watch "gotoLine", (value) =>
|
||||||
console.log "Going to line", value
|
console.log "Going to line", value
|
||||||
|
|
|
@ -42,7 +42,9 @@ define [
|
||||||
else
|
else
|
||||||
@$originalApply(fn);
|
@$originalApply(fn);
|
||||||
|
|
||||||
window.editor = editor = Ace.edit(element.find(".ace-editor-body")[0])
|
editor = Ace.edit(element.find(".ace-editor-body")[0])
|
||||||
|
window.editors ||= []
|
||||||
|
window.editors.push editor
|
||||||
|
|
||||||
autoCompleteManager = new AutoCompleteManager(scope, editor, element)
|
autoCompleteManager = new AutoCompleteManager(scope, editor, element)
|
||||||
spellCheckManager = new SpellCheckManager(scope, editor, element)
|
spellCheckManager = new SpellCheckManager(scope, editor, element)
|
||||||
|
|
|
@ -47,6 +47,8 @@ define [
|
||||||
range = new Range(pos.row, pos.column, pos.row, pos.column + 1)
|
range = new Range(pos.row, pos.column, pos.row, pos.column + 1)
|
||||||
nextChar = editor.session.getTextRange(range)
|
nextChar = editor.session.getTextRange(range)
|
||||||
|
|
||||||
|
console.log "CALLING OLD"
|
||||||
|
|
||||||
# If we are in \begin{it|}, then we need to remove the trailing }
|
# 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}...
|
# since it will be adding in with the autocomplete of \begin{item}...
|
||||||
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
||||||
|
|
Loading…
Reference in a new issue