Skip to content

code-completion doesn't replace expected text when cursor is not at the end of name #10266

Closed

Description

@DanTup
  • VSCode Version: 1.4.0
  • OS Version: Windows 10

Steps to Reproduce:

  1. Create a method called methodOne
  2. Write some code that calls this method as methodTwo()
  3. Place the cursor between the d and T and invoke completion
  4. Select methodOne from the completion list

You would expect methodTwo to be replaced with methodOne but you end up with methodOneTwo.

Activity

  1. added
    typescriptTypescript support issues
    bugIssue identified by VS Code Team member as probable bug
    on Aug 8, 2016
  2. dbaeumer commented on Aug 8, 2016

    @dbaeumer
    Member

    Johannes Rieken (@jrieken) is there anything special I need to do to achieve this?

  3. DanTup commented on Aug 8, 2016

    @DanTup
    ContributorAuthor

    If it helps, my Dart extension seems to handle this correctly:

    https://github.com/DanTup/Dart-Code/blob/master/src/dart_completion_item_provider.ts#L41

    You can provide a textEdit property on the CompletionItem with a Range to replace. The Dart language service I'm using already returned the correct length here so it just worked out of the box. I guess in your MyCompletionItem class you may need to set up the textEdit (assuming you have all the necessary info from the service).

  4. dbaeumer commented on Aug 8, 2016

    @dbaeumer
    Member

    I don't :-(. I can reconstruct this using may be model API but I was hoping not being forced to do this and Johannes Rieken (@jrieken) knows a better way.

    If we need this information to handle cases like this then it should IMO come from the tsserver since he has the full knowledge about the context of the code complete.

  5. jrieken commented on Aug 8, 2016

    @jrieken
    Contributor

    When a completion item doesn't specify a text edit we construct one with the word range until the current position. So, you can achieve the behaviour using a different range or we just change our default - tho that makes it sound more like a user option cos I am not sure if overwrite after is always the right thing to do?

  6. dbaeumer commented on Aug 8, 2016

    @dbaeumer
    Member

    Changing the default is not a good thing to do since we will break others. I will see if I can recompute this for now and make a request against the tsserver to better provide this info.

  7. jrieken commented on Aug 8, 2016

    @jrieken
    Contributor

    You can always ask for the word range at position. That's usually a pretty good guess

  8. dbaeumer commented on Aug 8, 2016

    @dbaeumer
    Member

    Agree.

  9. dbaeumer commented on Aug 26, 2016

    @dbaeumer
    Member

    Johannes Rieken (@jrieken) and I discussed that again over lunch and we agreed that we should investigate into a language neutral solution to not have to many language specific settings. Moving to September and adding Johannes Rieken (@jrieken) as an owner.

  10. 93 remaining items

  11. jrieken commented on Dec 2, 2019

    @jrieken
    Contributor

    We not gotten enough feedback to finalise this API and will push things out for another milestone. Tho, the setting and the default behaviour will ship.

  12. ctf0 commented on Dec 20, 2019

    @ctf0

    isnt this covered with "editor.suggest.insertMode": "replace"

  13. DanTup commented on Dec 23, 2019

    @DanTup
    ContributorAuthor

    Muah (@ctf0) that functionality only works if the language extension provides two ranges to VS Code. There's an issue tracking handling that for TS at #87091.

  14. AlGantori commented on Feb 29, 2020

    @AlGantori
  15. locked and limited conversation to collaborators on Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions