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

Insert final newline moves cursor #79927

Closed
sumneko opened this issue Aug 27, 2019 · 12 comments · Fixed by microsoft/azuredatastudio#7206
Closed

Insert final newline moves cursor #79927

sumneko opened this issue Aug 27, 2019 · 12 comments · Fixed by microsoft/azuredatastudio#7206
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@sumneko
Copy link
Contributor

sumneko commented Aug 27, 2019

Steps to Reproduce:

  1. Set Files: Insert Final Newline to true.
  2. Input some words in a ts file.
  3. View the competion items in competion hover.
  4. VSCode inserts the final newline and close the competion hover.
  5. Frustrated.

关闭completion

@jrieken jrieken added info-needed Issue requires more information from poster suggest IntelliSense, Auto Complete labels Aug 28, 2019
@jrieken
Copy link
Member

jrieken commented Aug 28, 2019

VSCode inserts the final newline and close the competion hover.

Sorry, I don't understand what's happening here. Do you accept a completion? How/why does the widget close? Are pressing any key? Can you reproduce without extensions? What version of VS Code is this?

@sumneko
Copy link
Contributor Author

sumneko commented Aug 28, 2019

VSCode inserts the final newline and close the competion hover.

Sorry, I don't understand what's happening here. Do you accept a completion? How/why does the widget close? Are pressing any key? Can you reproduce without extensions? What version of VS Code is this?

  1. I did not accept any completion.
  2. The widget closed by VSCode due to inserting final newline.
  3. Dose not press any key except down arrow (This key has nothing to do with the problem.).
  4. This can be reproduced without any extensions.
  5. VSCode version:
版本: 1.37.1 (user setup)
提交: f06011ac164ae4dc8e753a3fe7f9549844d15e35
日期: 2019-08-15T16:17:55.855Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@jrieken
Copy link
Member

jrieken commented Aug 28, 2019

This can be reproduced without any extensions.

Sorry, no. I cannot reproduce. Please follow these steps to really disable extensions. Select 'Extensions View > ... > Disable all Installed Extensions', reload, and try again. Thanks.

screen shot 2018-05-09 at 08 45 10

@sumneko
Copy link
Contributor Author

sumneko commented Aug 28, 2019

This can be reproduced without any extensions.

Sorry, no. I cannot reproduce. Please follow these steps to really disable extensions. Select 'Extensions View > ... > Disable all Installed Extensions', reload, and try again. Thanks.

screen shot 2018-05-09 at 08 45 10

Only reproduced when editing the last line, I forgot to mention this key point. It's my mistake.

@sumneko
Copy link
Contributor Author

sumneko commented Aug 28, 2019

final newline

@sumneko
Copy link
Contributor Author

sumneko commented Aug 28, 2019

I did a further test, to reproduce this, the following conditions must be met simultaneously:

  1. Set Files: Insert Final Newline to true.
  2. Set Files: Auto Save to afterDelay.
  3. Input on the last line.

@jrieken jrieken added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Aug 28, 2019
@jrieken
Copy link
Member

jrieken commented Aug 28, 2019

Thanks. I can reproduce now.

@jrieken
Copy link
Member

jrieken commented Aug 28, 2019

Ok, full steps

  • enable final newline insertions
  • enable auto save
  • type and trigger suggest on the very last line
  • wait a little
  • 🐛 suggest widget closes

The debugger state below shows what's happening. The insert final newline logic kicks in (while suggest is active) and ends up moving the cursor position (from line 42 to line 43). Because the cursor moves suggest cancels and hides the widget.

Screenshot 2019-08-28 at 10 25 28

@jrieken jrieken removed the suggest IntelliSense, Auto Complete label Aug 28, 2019
@jrieken jrieken removed their assignment Aug 28, 2019
@jrieken jrieken changed the title Insert final newline closed the completion hover. Insert final newline moves cursor Aug 28, 2019
@bpasero
Copy link
Member

bpasero commented Aug 28, 2019

@alexandrudima need your advice here, in the end I call:

model.pushEditOperations(prevSelection, [EditOperation.insert(new Position(lineCount, model.getLineMaxColumn(lineCount)), model.getEOL())], edits => prevSelection)

I think this is not just about inserting a final new line but any edit operation can potentially close suggest.

Btw for me the cursor does not move, but suggest still closes.

@jrieken
Copy link
Member

jrieken commented Aug 28, 2019

Btw for me the cursor does not move, but suggest still closes.

Maybe that's an intermediate cursor state?

@alexdima
Copy link
Member

@bpasero I think because the edits are done directly on the model, the cursor of the current editor can only adjust to the edit. It would be better if the edits would be done through the current editor. i.e. ICodeEditor.executeEdits

@bpasero bpasero added this to the August 2019 milestone Aug 28, 2019
@bpasero
Copy link
Member

bpasero commented Aug 28, 2019

I pushed both a fix in cursor.ts with Alex and adopted the ICodeEditor.executeEdits. I stayed away from using it for other places where we use the model edit.

hunghw pushed a commit to hunghw/vscode that referenced this issue Aug 28, 2019
@octref octref added the verified Verification succeeded label Aug 29, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants