Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
XamSyntaxEditor not handling carriage return correctly


I face a strange error with xamSyntaxEditor: I am loading the content with \n characters and this works correctly. However doing simple replace to have \r\n also correcting the linefeed setting and then loading to the editor reads the content with syntax errors (nothing else is changed). I've investigated errors and all were caused by string end determination at the end. It was taking additional double quote character and resulting with invalid line end (missing closing tag). Strangely doing 2 changes (no replacement of new line feed + restore setting) works without problems again.

I've created the sample project with xamSyntax editor. However I am not able to submit it due too much sensitive information. Please contact me via email so I can send a sample.

Original source based here:

Regex used for replacing \n to \r\b ( Regex.Replace(value, "(?<!\r)\n", "\r\n");):

		internal static string ToStabilizeNewLineString(this string value)
			if (string.IsNullOrEmpty(value) || value.IndexOf('\n') < 0)
				return value;

			return Regex.Replace(value, "(?<!\r)\n", "\r\n");

Setting editor parameter in XamSyntaxEditor inheritor class:

Document.NewLineSequence = NewLineSequence.LineFeed;

Here is error example:

Errors at the end of method

  • 28970
    Offline posted

    Hello Tomas,

    Since the sample project is sensitive, I have made the back-end private support case to this forum thread visible to you. It has an ID of CAS-199917-M2R5H7, and you can access it through your account on the Infragistics website, here. Please attach the sample project to that support case. If you would like, we can also handle this issue through that case was well.