From e366ebd34ce532568e6d77102c28474b5cad3547 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 13 Feb 2024 19:29:11 +0100 Subject: [PATCH] Resolve deprecation warnings for ACE Editor 1.32.6 --- app/assets/javascripts/editor.js | 2 +- app/assets/javascripts/editor/editor.js.erb | 6 +++--- app/assets/javascripts/exercises.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 4f31c3ab..28e94335 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -16,7 +16,7 @@ $(document).on('turbolinks:load', function(event) { if ($('#editor').isPresent() && CodeOceanEditor && event.originalEvent.data.url.includes("/implement")) { // This call will (amon other things) initializeEditors and load the content except for the last line // It must not be called during page navigation. Otherwise, content will be duplicated! - // Search for insertLines and Turbolinks reload / cache control + // Search for insertFullLines and Turbolinks reload / cache control CodeOceanEditor.initializeEverything(); } diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 56288f7d..65bd66df 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -282,14 +282,14 @@ var CodeOceanEditor = { var editor = ace.edit(element); var document = editor.getSession().getDocument(); - // insert pre-existing code into editor. we have to use insertLines, otherwise the deltas are not properly added + // insert pre-existing code into editor. we have to use insertFullLines, otherwise the deltas are not properly added var file_id = $(element).data('file-id'); var content = $('.editor-content[data-file-id=' + file_id + ']'); this.setActiveFile($(element).parent().data('filename'), file_id); - document.insertLines(0, content.text().split(/\n/)); + document.insertFullLines(0, content.text().split(/\n/)); // remove last (empty) that is there by default line - document.removeLines(document.getLength() - 1, document.getLength() - 1); + document.removeFullLines(document.getLength() - 1, document.getLength() - 1); editor.setReadOnly($(element).parent().data('read-only') !== undefined); if (editor.getReadOnly()) { editor.setHighlightActiveLine(false); diff --git a/app/assets/javascripts/exercises.js b/app/assets/javascripts/exercises.js index 77523096..37429941 100644 --- a/app/assets/javascripts/exercises.js +++ b/app/assets/javascripts/exercises.js @@ -15,13 +15,13 @@ $(document).on('turbolinks:load', function () { var editor = ace.edit(element); var document = editor.getSession().getDocument(); - // insert pre-existing code into editor. we have to use insertLines, otherwise the deltas are not properly added + // insert pre-existing code into editor. we have to use insertFullLines, otherwise the deltas are not properly added var file_id = $(element).data('file-id'); var content = $('.editor-content[data-file-id=' + file_id + ']'); - document.insertLines(0, content.text().split(/\n/)); + document.insertFullLines(0, content.text().split(/\n/)); // remove last (empty) that is there by default; disabled due to missing last line - // document.removeLines(document.getLength() - 1, document.getLength() - 1); + // document.removeFullLines(document.getLength() - 1, document.getLength() - 1); editor.setReadOnly($(element).data('read-only') !== undefined); editor.setShowPrintMargin(false); editor.setTheme(CodeOceanEditor.THEME);