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

Selecting suggestion of string completion deletes everything up to end of line, if no ending quote is present #58438

Open
psznm opened this issue May 5, 2024 · 0 comments

Comments

@psznm
Copy link

psznm commented May 5, 2024

πŸ”Ž Search Terms

completion autocompletion string

πŸ•— Version & Regression Information

  • This issue is new in typescript 5.5.0-beta
  • Not fixed in nightly at time of submitting issue.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.5.0-beta#code/C4TwDgpgBAKhDOwoF4oHJgOGg3AKAHoCoAFAGwgEN4IAaKYAJxAYHsoBjVgWzAswYALaJkRQARiwDCTMgFp4YSh2iUAdgBMhENVBoUOwAJZqA5noCup01iOs1eLmrGjgALlhYU6bDihEYQSN4KAB3VkYAaxCAMxMIR3sXLAAmDzgxVAw-IlggkI0IOLUjTDIWeEFWCzItNVYkGyRC-ggte04ePghje3pxCA5KCxooUs6arQGx3gjgdSQuQv6LJHGNVgRE5yRXAGZ0r1QAImAc4kDgqELi0ohyvSrJqHrGnuv7nraoDq5efjsan6g2Go3GXGe0yMs0Y8zUi1YywkqzGzU28DwhGIACUispgBETOYIAAPSj-aChYSMET5CQQQSUABudkYYxC4koGgAdLBmHpPoYiZZrLYOjFGDwoKdjmxpa5jttkogACweADeUDAkrAAEYPGoLNwBox6NrWGA0i8jSaoABfbzq816jwAVjNOqtKXt+CcyuAro1zoADIdEB6LfrrcaIKatZ6DTbY-R7Y74xbQz4oLRnVH3enLR5vXb8LkpF0AR0TFBXdzXVAafAasAQgSoErdlgAGxBnWZjLACMu6MmodWw0xuOp1CakMeDBYLFQcsU3q6au1lV1hsIZut9gdhhYADsvYzYcHBajE9HBfHSanDpnBczC7EOZ1ebHRZ9QA

πŸ’» Code

type Test = 'test';
// Please, try to complete the test by Ctrl-space and then selecting suggestion
const test: Test = 't'; //This works fine
const test2: Test = 't; // This comment definitely should not get deleted on completion, because it could be important code, but it does
const test3: Test = "t; // This comment  definitely should not get deleted on completion, because it could be important code, but it does

// Refactoring example where this behavior is bad. Try selecting suggestion from "t" to "test"
const test4: { prop1: number, prop2: number } = {prop1: 5, prop2: 2 };
const test5: {prop0: Test, prop1: number, prop2: number,  } = { prop0: 't ,prop1: 5, prop2: 2 };
// Completion in 5.5 results to 
const test6: {prop0: Test, prop1: number, prop2: number,  } = { prop0: 'test
// Completion in 5.4.5 results to 
const test7: {prop0: Test, prop1: number, prop2: number,  } = { prop0: 'test ,prop1: 5, prop2: 2 };

πŸ™ Actual behavior

When trying to complete "t" to "test" in the code for variables test2, test3, everything up to the end of line gets deleted.

This is especially bad when trying to add new string properties to existing objects, as can be seen by example refactoring of test4 to test5 variable. Where poor result of selected suggestion can be seen in test6 variable and good behavior of previous TS versions in test7 variable.

πŸ™‚ Expected behavior

When editing new string, typescript should insert suggestions, not replace content. Previous versions behavior seems perfect to me.

Additional information about the issue

EDIT: updated example, one of the previous examples didn't behave very well even in previous versions. Added demonstration of previous good behavior.

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant