Bug 11014 - Format selection and on fly code formatting does not work
Summary: Format selection and on fly code formatting does not work
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: Trunk
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2013-03-09 04:24 UTC by Sergey Zhukov
Modified: 2013-03-11 16:44 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

program.cs (301 bytes, text/x-csharp)
2013-03-09 04:24 UTC, Sergey Zhukov
patch (868 bytes, patch)
2013-03-10 09:41 UTC, Sergey Zhukov

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Sergey Zhukov 2013-03-09 04:24:35 UTC
Created attachment 3563 [details]

Description of Problem:

Format selection does not work, also on fly code formatting does not work. 

Steps to reproduce the problem:
1. Create new console project, insert into Program.cs attached file
2. Select region from opening brace to closed brace, marked with comments ('select region from here' to 'end of region selection'.
3. Choose Edit/Format selection
remove matching brace after the comment 'place closing brace after the comment on new line' and place it againg.  

Actual Results:
no reformatting is happened

Expected Results:
three lines 
int x; 
int y;
//place closing 
will indent one column right

How often does this happen? 

Additional Information:
If you choose Edit/Format Document. Document will be reformatted as expected

Version info

=== MonoDevelop ===

Version 4.0
Installation UUID: d9cda119-9de4-45aa-bf0c-3eb117ac80e6
	Mono 3.0.7 (master/7c704df Sat Mar  9 03:26:42 NOVT 2013)
	GTK 2.24.10
	GTK# (

=== Build Information ===

Git revision: a2b28c697b8e0ff28201b2546491e9cf18536a68
Build date: 2013-03-08 21:06:23+0000

=== Operating System ===

Linux 3.2.0-38-generic-pae #61-Ubuntu SMP Tue Feb 19 12:39:51 UTC 2013 i686 i686 i386 GNU/Linux
Comment 1 Sergey Zhukov 2013-03-10 09:41:06 UTC
Created attachment 3568 [details]

This patch fixes the error for me. Not sure it's 100% correct, because Ide allows to format empty selections and I don't know what is the correct behaviour for this activity. I think creating right formattingRegion in the 				if (seg != null && seg == seg2) {}
 of Format function in OnTheFlyFormatter.cs  would be more correct solution
Comment 2 Mike Krüger 2013-03-11 07:34:25 UTC
Comment 3 Mike Krüger 2013-03-11 07:34:46 UTC
btw. I corrected the formatting region - it wasn't set correctly.
Comment 4 Sergey Zhukov 2013-03-11 12:24:52 UTC
I checked the latest commits. On fly formatting works correctly now, but "format selection" still not format selected region (if you select region from opening brace to closed brace)
Comment 5 Mike Krüger 2013-03-11 12:54:46 UTC
Good that you checked it :) - it worked for me earlier ... but you're right this case is broken.

Comment 6 Sergey Zhukov 2013-03-11 15:15:36 UTC
Verified. Works as expected.
Comment 7 Mike Krüger 2013-03-11 15:57:15 UTC
btw. it's nice that you looked at the source code :) - we could need more people helping out with the development.
Comment 8 Sergey Zhukov 2013-03-11 16:44:11 UTC
I'd like to help you in dev where I can.