Bug 17548 - pasting code doesn't respect formatting
Summary: pasting code doesn't respect formatting
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.2.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 4.2.4 (from master)
Assignee: Mike Krüger
Depends on:
Reported: 2014-02-02 08:23 UTC by Andy
Modified: 2014-02-18 03:05 UTC (History)
5 users (show)

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

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 Andy 2014-02-02 08:23:44 UTC
At least for custom brace indentation
Comment 1 Prashant manu 2014-02-03 02:49:40 UTC
We are not observing this behavior. Could you please provide us screenshot/test steps for this.

Environment info:
XS 4.2.2 (build 2)
Comment 2 Mike Krüger 2014-02-03 02:59:25 UTC
btw. copy & paste reindents the code - if that's your issue then it's a feature
Comment 3 Andy 2014-02-03 07:16:00 UTC
Set brace indentation in settings
Wrote code that has two braces. It is indented. (Not always but most times)
Cut this code
Paste it
Braces are not indented
Comment 4 Mike Krüger 2014-02-03 07:59:37 UTC
Did you set the indentation in the project options or in the ide options ?

A screencast would really help us to understand your exact use case.

Note that the projects overwrite the IDE settings & the IDE settings are applied to new projects only.
Comment 5 Andy 2014-02-03 08:05:13 UTC
So you mean that when I write code it uses one set of options, then when I paste it it uses a different one ? Sounds like an entirely different bug then !

Regardless of where i set them, shouldn't this behavior be consistent ??? If I write code or paste it, the indentation should be the same, right ?

Anyway, I usually set them in solution options.
Comment 6 Andy 2014-02-03 09:54:02 UTC
I just checked: Project has 'inherited' as code formatting settings. All settings I've always done were at the Application level.
Comment 7 Mike Krüger 2014-02-04 02:02:59 UTC
Ok if you set them at solution level then you're right that it had a bug. 
The next release will fix that.

*** This bug has been marked as a duplicate of bug 15962 ***
Comment 8 Andy 2014-02-04 04:02:58 UTC
I still don't understand it. When I write code, the braces are indented, so it works. 
When I paste it, it does not work. 

I can't understand why this is an issue with application/solution settings. In that case it should never work not even while writing code.
Comment 9 Mike Krüger 2014-02-04 05:10:19 UTC
Ok what do you mean with it works when writing and it does not work on paste ?

What should happen on paste and what doesn't happen ?
Comment 10 Andy 2014-02-04 05:22:06 UTC
1) Write code -> braces are indented on brace close (correct)
2) Paste same code -> braces are NOT indented (incorrect)

n 2) happens even if you copy/cut the code at 1) which is correctly indented
Comment 11 Mike Krüger 2014-02-04 05:26:42 UTC
Doesn't make much sense to me - for me that works:


Note that paste only corrects indenting & doesn't correct formatting.
(We had too much trouble with running the formatter there - most people regard this behavior as bug)
Comment 12 Andy 2014-02-04 05:29:31 UTC
try this:

1) set in settings: Braces go next line shifted
2) write this code:


3) notice that closing the brace makes both braces shift one tab (Console line is shifted too)

4) cut that code

5) paste that code

6) notice that both braces are now NOT indented
Comment 13 Mike Krüger 2014-02-04 05:46:08 UTC
ok that's something I can reproduce & fix

Comment 14 Andy 2014-02-04 06:02:02 UTC
Ok. Seems to me most indentation bugs revolve around next line shifted. Perhaps it wasn't tested that much ?
Comment 15 Mike Krüger 2014-02-04 06:10:51 UTC
Unfortunately y :/ - it's something I implemented in the formatting options several years ago and it got forgotton because almost no one uses that.

But I it'll get better - I added some unit tests in the indentation engine for that. (The formatting should work)
Comment 16 Andy 2014-02-04 06:18:12 UTC
I see. However I would be wary to assume that since nobody reported it nobody uses it.

Most bugs I report are seen by other people I know that simply have up using buggy functionality....
Comment 17 Mike Krüger 2014-02-04 06:22:11 UTC
y  - that's why I said 'almost' I don't think that you're the only one. But I would guess that I get bug reports from 1 of 100 people seeing it.

Reporting bugs is more important than most people think :/
Comment 18 Andy 2014-02-04 06:27:28 UTC
1 out of 100 I think is a fair estimate. It's also a percentage that goes way down the more bugs are found. 
I am now reporting something close to 100 bugs, which I had noticed for a long while, but I was just evaluating if it was worth my time or if I would better use some other workaround / tool. 
A friend of mine was in the same spot but took the opposite course and just gave up.
Reporting bugs is important, and it's commendable that you keep track on them, but sometimes one is discouraged if he sees too many (but I'm especially referring to the VS plugin)
Comment 19 Sadik Ali 2014-02-17 10:08:47 UTC
I tried to reproduce this issue at my end but unable to reach option "set in settings: Braces go next line shifted" which is mentioned in comment 12.

Please guide me how to set this option.
Comment 20 Andy 2014-02-17 10:55:47 UTC
it's in the section where you choose where to position braces. there are multiple comboboxes where you can choose among other settings 'next line shifted'
Comment 21 Sadik Ali 2014-02-18 03:05:05 UTC
I have verified this issue on below environment:

All Mac
Xamarin Studio 4.2.4 (build 17)
Build Information
Release ID: 402040017
Git revision: 00b6aafbd9d5b59499aa5f9e7ba274f55ed95d5d
Xamarin addins: 2debf1c1984b1d3d8312decda84dc966b7412433

I followed below steps: 

1. Set Braces "next line shifted" for Statements.
2. Created console project.
3. Write below code:


4. Cut and past.
5. Observed that both braces and console statement shifted one tab.

Refer screen cast: http://screencast.com/t/15AO0EmCIq9