AvaloniaUI / AvaloniaVS

Visual Studio Extension for Avalonia
MIT License
422 stars 81 forks source link

Adding nested Tag renames parent closing element #338

Closed Mrxx99 closed 1 year ago

Mrxx99 commented 1 year ago

Describe the bug

When typing a nested Tag like <UserControl.Styles> it renames the closing Tag of the parent UserControl instead of leaving this intact and adding it's own closing tag like for other not nested Tags (e.g. a Control). This is pretty annoying and breaks the flow of typing.

To Reproduce

  1. Open a UserControl
  2. Inside type character by character (not copy-paste):

Observe how the parent UserControl tag gets renamed and the file invalid.

AvaloniaVS_AddNestedTag

AvaloniaVS plugin version

0.10.18.3

Avalonia version

11.0.0-rc1.1

Visual Studio version

17.7.0 Preview 1.0 & 17.5.4

Relevant log output

19:21:02.428 [Error] 19516 UpdateXamlResult error
System.Xaml.XamlException: 'Name cannot begin with the '
' character, hexadecimal value 0x0D. Line 10, position 4.' Line number '10' and line position '4'.
19:21:03.161 [Error] 19516 UpdateXamlResult error
System.Xaml.XamlException: 'Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 12, position 3.' Line number '12' and line position '3'.
19:21:04.115 [Error] 19516 UpdateXamlResult error
System.Xaml.XamlException: 'Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 12, position 3.' Line number '12' and line position '3'.
19:21:04.943 [Error] 19516 UpdateXamlResult error
System.Xaml.XamlException: 'Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 12, position 3.' Line number '12' and line position '3'.
19:21:05.382 [Error] 19516 UpdateXamlResult error
System.Xaml.XamlException: 'Unexpected end of file has occurred. The following elements are not closed: UserControl. Line 14, position 1.' Line number '14' and line position '1'.

Additional context

Note: this does only happen with the Avalonia extension installed, without it, the default XML editor used than behaves correctly.

workgroupengineering commented 1 year ago

Can you try PR #340. The artifcat is here.

Mrxx99 commented 1 year ago

@workgroupengineering Tried the PR. It did improve it in some way but it still can happen. It seem if you type slowly it still happen, but if you accept the suggestion fast it does not:

AvaloniaVS_AddNestedTag_notfix