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

Enter key stops working #12

Closed
katbow opened this issue Aug 13, 2018 · 4 comments
Closed

Enter key stops working #12

katbow opened this issue Aug 13, 2018 · 4 comments

Comments

@katbow
Copy link

katbow commented Aug 13, 2018

I reported the issue here: microsoft/vscode#53972

The enter key stops working and won't go to the next line. It's unclear how to replicate, as it happens seemingly at random. It only fixes itself after restarting vscode, or disabling/re-enabling the extension.

Since removing endwise, I haven't had this problem anymore.

@kaiwood
Copy link
Owner

kaiwood commented Aug 19, 2018

Hmm. To make this extension work, we completely overload the enter key and handle line breaks and stuff. As you said its random, my guess would be that the extension host is crashing and the associated command does no longer execute.

But: It doesn't have to be this extension that is causing the host crash, I've seen this behaviour with a couple of other commands too in the past.

If it happens again, would you mind checking the Developer Tools (Menu Help->Toggle Developer Tools) and share the most recent lines from there? That might give at least a clue where to start looking…

@wulffeld
Copy link

wulffeld commented Sep 7, 2018

I just now had the same issue. It only happens to certain files and disabling endwise fixed the issue. I restarted code several times as well.

I managed to reproduce the issue with this file:

#
module A
  module B
    module C
      module D
        module E
          class F

            description <<-EOD.strip_heredoc
            Blah blah
            EOD

          end
        end
      end
    end
  end
end

When I hit enter the Code Helper process goes to 100% cpu.

@wulffeld
Copy link

UPDATE: Well I've now done another couple of hours of extension wack a mole and I apologize because it seems endwise is not the issue. Not sure how I got to that in the first round.

The offending extension for me is highlight-matching-tag.

@kaiwood
Copy link
Owner

kaiwood commented Sep 15, 2018

@wulffeld Already thought so, the code example didn't look to fancy to cause a problem in itself.

The way VSCode's extension architecture is designed makes it a little tough to find the proper cause of a freeze. There is a clear separation with the extension host running in a separate process to protect the editor itself from misbehaving plugins, which is brilliant.

But on the other side of the fence, all extensions run in the same process and have pretty much the same problem as every Node application: If a part of the system blocks the event loop, everyone gets stuck.

When I started this extension, I already had a bad gut feeling realising that I need to take over the Enter key completely as a keybinding. Not only does it need to handle the "end" 2 lines below the current cursor position, it literally writes the newline symbol, figures out the auto-indentation that would normally occur and then moves the cursor to the end of the next line.

I would have really preferred to just listen to a keypress event, let VSCode do its thing on the first line and only handle the next one appending the "end". But there is currently no API for doing so (as I remember, there was a reasoning behind not having keypress events).

Long story short, as soon as something is available to either use keypress events or release the binding when the extension host freezes, I try to work around this problem. But currently we are stuck with this and can only hope that other extension authors write code that doesn't crash. (But hey, at least I can now blame other programmers from time to time, that's nice too :D)

@kaiwood kaiwood closed this as completed Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants