mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.17k stars 180 forks source link

REPL: Duplicate newlines when evaluating expressions #1052

Closed wookayin closed 9 months ago

wookayin commented 9 months ago

Debug adapter definition and debug configuration

This bug has nothing to do with any particular adapters, but one can use lua adapter for simple reproducibility:

  local dap = require('dap')

  dap.configurations.lua = {
    {
      type = 'nlua',
      request = 'attach',
      name = "Attach to running Neovim instance",
    }
  }

  dap.adapters.nlua = function(callback, config)
    callback({
      type = 'server',
      host = config.host or "127.0.0.1",
      port = config.port or 8086
    })
  end

Debug adapter version

https://github.com/jbyuki/one-small-step-for-vimkind

Steps to Reproduce

  1. Open a DAP session and enter the REPL window
  2. Type any expressions to evaluate, press <CR> to enter the line in the REPL

e.g., evaluate a local variable a, and constant expressions 1, 2, 3, etc.

Expected Result

dap> a
7
dap> 1
1
dap> 2
2
dap> 3
3
dap> |

(| means the current cursor)

Actual Result

Extra "dap> " lines are added before the evaluation result being printed:

dap> a
dap>
7
dap> 1
dap>
1
dap> 2
dap>
2
dap> 3
dap>
3
dap> |

75a94b8b577a970c0cad25a54a64dc40fc6fa0ea (#889) is the first bad commit after bisecting /cc @ktakiman @mfussenegger

ktakiman commented 9 months ago

Darn it. Thanks for letting me know @wookayin ! I'll give a shot at fixing it - @mfussenegger

ktakiman commented 9 months ago

@wookayin here is a candidate fix if you'd like to give it a test spin :) I'll test it for at least a few days. If everything looks OK, will make a PR. Thanks!