Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvim hangs while editing JavaScript object literals in an HTML file after first opening a JavaScript file #9264

Closed
darthmall opened this issue Nov 21, 2018 · 4 comments
Labels
bug-vim wrong behavior inherited from vim runtime funtime
Milestone

Comments

@darthmall
Copy link

darthmall commented Nov 21, 2018

This is a little bizarre, so bear with me. If I try to insert a JavaScript object inside another JavaScript object in a script tag in an HTML file after having opened another JavaScript file first, nvim will hang. I can see in top that its CPU usage spins up to 100%. The steps below will probably make this more clear.

  • nvim --version: 0.3.1
  • Vim (version: 8.0) behaves differently? Yes, I wasn't able to reproduce this in Vim8
  • Operating system/version: Ubuntu 18.04
  • Terminal name/version: GNOME Terminal 3.28.2
  • $TERM: xterm-256color and screen-256color

Steps to reproduce using nvim -u NORC

  1. nvim -u NORC foo.js
  2. :vs index.html
  3. Add the following lines to index.html
<script>
  var x = {
  }
</script>
  1. Insert a property y: {} into the object x
 <script>
   var x = {
+    y: {
+    }
   }
 </script>

Actual behaviour

As soon as you hit enter after the opening { in y: {, nvim becomes unresponsive.

This only happens if you have opened another JavaScript file first. If you nvim -u NORC index.html and then :vs foo.js and add the same HTML to index.html, it works fine. Also, if you insert the } before you insert the {, it works fine.

And if you start nvim with -u NONE instead of NORC, it works.

Expected behaviour

Nvim should continue to function normally after typing y: {\n.

Updated 21 Nov. 2018 16:42 -0700 to correct the steps to reproduce, see my comment below.

@mhinz
Copy link
Member

mhinz commented Nov 21, 2018

FWIW, I can't reproduce it with 0.3.1 from Homebrew, but since it happens on an opening bracket, it might be related to the standard plugin matchparen (:h matchparen).

Does executing :NoMatchParen before adding the y: {} line avoid the issue?

@darthmall
Copy link
Author

I just realized there was a subtle error in how I described reproducing the bug. It's not entering the { that causes nvim to hang, it's hitting enter after the {. So the lines you're actually adding are:

 <script>
   var x = {
+    y: {
+    }
   }
 </script>

So really this has something to do with inserting a new line after the {. I can enter y: {} just fine, but as soon as I try to add a newline in between the {} it crashes.

Setting :NoMatchParen doesn't change anything for me.

@mhinz
Copy link
Member

mhinz commented Nov 22, 2018

Ah, there you go. I can reproduce it like that. (You can break it via <c-c>.)

I wasn't closely following recent changes, but I can confirm that it's fixed on master and will work in the next release.

@justinmk
Copy link
Member

We are up-to-date with Vim's runtime changes, so that explains why it's fixed on master.

@justinmk justinmk added runtime funtime bug-vim wrong behavior inherited from vim labels Nov 22, 2018
@justinmk justinmk added this to the 0.3.2 milestone Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-vim wrong behavior inherited from vim runtime funtime
Projects
None yet
Development

No branches or pull requests

3 participants