microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.4k stars 28.95k forks source link

vscode seems don't handle newline and tab correctly in snippet string provided by inlineCompletionProvider #193363

Open perfecking opened 1 year ago

perfecking commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce: inline_completion.zip inline_badcase.zip https://github.com/microsoft/vscode/assets/4253318/deee8444-00b0-4b20-8ed9-603ee44e98b0

屏幕录制2023-09-18-19 54 48

  1. Unzip the inline_inline_badcase.zip file, which contains the problematic case file.
  2. Unzip the inline_completion.zip file and build the test extension. Then, run the extension and open the above-mentioned case file as the workspace. (npm install && npm run vscode:prepublish , then run it)
  3. Go to line 5 in the editor and type something before the word 'else:' end. You will notice that some ghost inline completion text is generated, and its format is correct. However, after pressing the tab key to accept it, the file becomes corrupted, with additional tabs inserted at the beginning of each line.

I have also attached a GIF to demonstrate this issue. Thank you for any assistance in resolving this problem.

hediet commented 1 year ago

It would be awesome if you could reproduce your issue in the monaco editor playground.

As we have to be very careful when opening/running external source code from zip files, a playground example would significantly speed up the process.

perfecking commented 1 year ago

It would be awesome if you could reproduce your issue in the monaco editor playground.

As we have to be very careful when opening/running external source code from zip files, a playground example would significantly speed up the process.

I'm glad to receive your reply so fast. As you mentioned, I successfully reproduce the issue in the Monaco Editor playground. I have attached a GIF to demonstrate this issue. Thank you.

屏幕录制2023-09-18-23 38 39

ps: I have attached related source code, and append '.txt' suffix so that i can upload. extension.ts.txt def_hello.py.txt