elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

Can't disable auto closing of do/end block

Open thmzlt opened this issue 4 years ago • 8 comments

Environment

  • Elixir & Erlang versions (elixir --version): Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [hipe]

Elixir 1.10.3 (compiled with Erlang/OTP 22)

  • VSCode ElixirLS version: 0.5.0
  • Operating System Version: linux 5.4.62

Troubleshooting

  • [x] Restart your editor (which will restart ElixirLS) sometimes fixes issues
  • [x] Stop your editor, remove the entire .elixir_ls directory, then restart your editor

Issue

When I type do to start a block and press Enter, VS Code automatically adds a matching end on the next line. It doesn't seem to be possible to disable that behavior.

thmzlt avatar Sep 12 '20 14:09 thmzlt

Hi, you are correct that it is not currently possible to control that behavior. On the ElixirLS side that is controlled by ElixirLS.LanguageServer.Providers.OnTypeFormatting. A PR to enable/disable the automatic insertion of end with a configuration setting would be accepted so I've marked this issue as an enhancement request.

axelson avatar Sep 16 '20 17:09 axelson

This would be great to be able to disable since the auto-closing doesn't correctly add closing parentheses for anonymous function arguments.

bbugh avatar Apr 03 '21 14:04 bbugh

Is there any workaround for this? Anything I use requiring do gets an end immediately inserted after with my cursor after the end, it causes more work than it saves and can run amok sometimes if I'm in the middle of a bunch of unclosed sections.

Faheetah avatar Apr 25 '21 02:04 Faheetah

To disable this I had to:

  1. Replace this line with {:ok, nil}
  2. Comment out two lines that add do and end to suggestions (this may not be necessary)

I also have "Editor: Accept Suggestions on Enter" set to "off"

This results in a bit saner experience for me!

michallepicki avatar Sep 03 '21 07:09 michallepicki

@michallepicki can you create a PR with your fix (and a config setting)

lukaszsamson avatar Dec 25 '21 11:12 lukaszsamson

@lukaszsamson I am no longer in need of that tweak, somehow do/end completion works good enough for me now - probably due to other changes done in the meantime... Sorry! I'm not even sure if my links are relevant any more, maybe.

michallepicki avatar Dec 25 '21 12:12 michallepicki

OK, I’m going to close it as it seems the issue is not relevant anymore

lukaszsamson avatar Dec 25 '21 12:12 lukaszsamson

Can you reopen this? It still isn't possible to disable the auto closing of do/end blocks, and the extension doesn't respect the "auto closing brackets" setting.

thmzlt avatar Dec 17 '22 17:12 thmzlt

@thmzlt I'm convinced you are mistaking autoclosing with snippet completions. You can disable do-end closing if you disable snippets with editor.suggest.showSnippets.

lukaszsamson avatar Jul 19 '24 13:07 lukaszsamson