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

C# editor pressing CTRL+BACKSPACE to erase a word causes an error dialog to appear when the word is an unclosed " #77401

Closed
vsfeedback opened this issue Mar 3, 2025 · 4 comments · Fixed by #77402
Labels

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version]
Tested with

  • Version 17.13.1
  • Version 17.13.2
  • Version 17.14.0 Preview 1.1

Use project types:

  • WPF
  • WinForms
  • Console

*The code editor for VB doesn't have this issue.

Problem

I was erasing the string text in C# and I came across this error. I then replicated it down to simply having an unclosed double quote at the end of a line, if you CTRL+BACKSPACE to erase the quote you get an error about how 'end' must not be less than 'start'.

For example. if you have this code:

private void button1_Click(object sender, EventArgs e)
{
    Clipboard.SetData("
    MessageBox.Show(RuntimeInformation.FrameworkDescription);
}

Place the caret at the end of the Clipboard line and press CTRL+BACKSPACE you'll trigger the error. It also happens simply by having an unclosed quote. Putting the caret at the end of the line with the single " and pressing the key combination triggers it:

private void button1_Click(object sender, EventArgs e)
{
    "
    MessageBox.Show(RuntimeInformation.FrameworkDescription);
}
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 3, 2025
@sharwell
Copy link
Member

sharwell commented Mar 3, 2025

This exception is being thrown in CSharpTextStructureNavigatorProvider.GetExtentOfWordFromToken:

@CyrusNajmabadi
Copy link
Member

Wouldn't is be

return (TextSpan.FromBounds(start, contentStart), TextSpan.FromBounds(contentStart, contentEnd), TextSpan.FromBounds(contentEnd, end));
sam?

@sharwell
Copy link
Member

sharwell commented Mar 3, 2025

It could be. I was going based on PerfView data and the stack could be off by a line. The exception is inside a call to TextSpan.FromBounds.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged Issues and PRs which have not yet been triaged by a lead label Mar 3, 2025
@Pyritie
Copy link

Pyritie commented Mar 27, 2025

The fix for this has made it so ctrl+backspace is now only deleting two tabs instead of the whole line, if you have a line with nothing but tabs.

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

Successfully merging a pull request may close this issue.

4 participants