syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

Scala / Ensime organize-imports command gets into an infite loop with hunk confirmation prompts #10915

Closed mdedetrich closed 4 years ago

mdedetrich commented 6 years ago

Description :octocat:

When applying the ensime-refactor-diff-organize-imports command on a Scala source file (using the Scala layer), spacemacs gets into an infinite loop when dealing with hunk collision

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: A prompt opens with the following text.

Please answer y or n. Hunk has already been applied; undo it? (y or n)

Answering y or n then opens up the following prompt

Hunk has already been applied; Undo it? (y or n)

You then go into an infinite loop between these prompts, the only way to get out of it is to process esc or by cancelling the command with C-g. Pressing y or n doesn't actually seem to confirm the command.

Expected behaviour: :heart: :smile: Typing in y or n actually confirms the prompt and applies the change. Either that or there is no prompt at all and it just changes the imports automatically.

System Info :computer:

Backtrace :paw_prints:

Debugger entered--Lisp error: (quit)
  signal(quit nil)
  y-or-n-p("Hunk has already been applied; undo it? ")
  diff-apply-hunk()
  ensime-refactor-diff-apply-hunks()
  ensime-refactor-diff-apply-silently("/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp")
  ensime-refactor-diff-handler((:procedure-id 1 :refactor-type organizeImports :diff "/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp"))
  #f(compiled-function (G13 G14 g714) #<bytecode 0x416a7d21>)(--buffer-- --cont-- (:ok (:procedure-id 1 :refactor-type organizeImports :diff "/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp")))
  apply(#f(compiled-function (G13 G14 g714) #<bytecode 0x416a7d21>) --buffer-- --cont-- (:ok (:procedure-id 1 :refactor-type organizeImports :diff "/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp")))
  (lambda (&rest --cl-rest--) (apply (function #f(compiled-function (G13 G14 g714) #<bytecode 0x416a7d21>)) '--buffer-- '--cont-- --cl-rest--))((:ok (:procedure-id 1 :refactor-type organizeImports :diff "/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp")))
  ensime-dispatch-event((:return (:ok (:procedure-id 1 :refactor-type organizeImports :diff "/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp")) 3) #<process ENSIME Scala>)
  ensime-process-available-input(#<process ENSIME Scala>)
  ensime-net-filter(#<process ENSIME Scala> "0000cb(:return\n  (\n    :ok (\n      :procedure-id 1\n      :refactor-type organizeImports\n      :diff \"/private/var/folders/ng/9wyv05tj5kb_223yz89k0kc0nx7lvc/T/ensime-diff-8403025337018751638.tmp\"\n    )\n  )\n  3)")
beyondpie commented 6 years ago

Is it a bug in ensime or just not working in spacemacs?

mdedetrich commented 6 years ago

@songpeng Its hard to tell from just looking at it, is there an easy way to find out? I guess I can try out a base emacs install with just ensime-emacs and see if I can replicate

beyondpie commented 6 years ago

how about using ensime in the vanilia Emacs?

mdedetrich commented 6 years ago

Sure thing, will try this on the weekend

jypma commented 6 years ago

I'm having the same issue with ensime 2.0.2 on vanilla emacs. The import reorg itself seemed to work fine.

allenjohnashton commented 6 years ago

I am having this issue on vanilla emacs as well.

mdedetrich commented 6 years ago

I also tried it with vanilla emacs and had the same issue, will try and report upstream

allenjohnashton commented 6 years ago

Can you link to the report I would like to add info. I am only experiencing this on linux but not on mac

allenjohnashton commented 6 years ago

@mdedetrich Have you reported upstream?

mdedetrich commented 6 years ago

@allenjohnashton Unfortunately I am really busy this week, I should be able to generate an issue by the end of the week

what-the-functor commented 5 years ago

Upstream PR ensime/ensime-emacs#702

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!