From 90fb77b878cf3d6ae6d27bea2070ef35c3c3c8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 9 Apr 2021 16:25:27 +0200 Subject: [PATCH] Disable do/end autocomplete in case it would move the cursor unexpectedly --- .../elixir/on_type_formatting_edit_provider.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/js/cell/live_editor/elixir/on_type_formatting_edit_provider.js b/assets/js/cell/live_editor/elixir/on_type_formatting_edit_provider.js index f301ee2dd..42eec720a 100644 --- a/assets/js/cell/live_editor/elixir/on_type_formatting_edit_provider.js +++ b/assets/js/cell/live_editor/elixir/on_type_formatting_edit_provider.js @@ -32,6 +32,14 @@ function closingEndTextEdits(model, position) { const shouldInsertInNextLine = position.lineNumber < lines.length && isBlank(line); + // If the next line is not available for inserting, + // we could insert `\nend` but this moves the cursor, + // so for now we just don't insert `end` at all + // For more context see https://github.com/elixir-nx/livebook/issues/152 + if (!shouldInsertInNextLine) { + return []; + } + const textEdit = insertClosingEndTextEdit( position, prevIndentation,