Bug 9787 - 3.x regression: Paste tries to be smart even though indent mode is not set to smart
Summary: 3.x regression: Paste tries to be smart even though indent mode is not set to...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 3.0.x
Hardware: Macintosh Mac OS
: Low normal
Target Milestone: ---
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-01-25 07:35 UTC by Rune Skovbo Johansen
Modified: 2013-01-25 08:06 UTC (History)
1 user (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Rune Skovbo Johansen 2013-01-25 07:35:42 UTC
When pasting text (as part of copy-paste or cut-and-paste) the indent of the pasted text uses smart indentation behavior even when indentation mode in preferences is not set to "smart".

Consider the following code, where the class is not indented relative to the namespace scope:

using System;

namespace Test
{

public class TestClass
{
	public void MyMethod (int number)
	{
		if (number == 0)
		{
			return 0;
		}
		
		return 1;
	}
		
}

}


In MonoDevelop 2.8, trying to copy-paste the method will paste the copied method with the same indentation as the source as expected. Similarly, trying to copy-paste the if-statement will paste it with the same indentation as the source as expected. This seems to be regardless of which indentation mode is selected. This may not be ideal behavior for Smart mode, but for Automatic mode, which is the one I care about, it's works as expected.

In MonoDevelop 3.0.x, trying to copy-paste the method will paste the copied method with one indentation level too much. Similarly, trying to copy-paste the if-statement will paste it one level indented too much. This seems to be regardless of indentation mode set. The behavior may be good for Smart indentation now, but it's completely unusable for code that doesn't have exactly one indentation level per nested scope.

Just in case the response to this is to claim that it's the user's fault for using incorrect indentation, then why have the Automatic indentation mode at all?

I consider it a bug that pasting does not respect the same logic that is used by the indentation mode used for typing.

Our codebase have lots and lots of files with classes inside namespaces where the classes are not indented. Currently using MonoDevelop 3.x for this codebase is not an option because of this pasting behavior.
Comment 1 Mike Krüger 2013-01-25 08:06:14 UTC
Fixed

You're using a specific code format - theoretically monodevelop allows this kind of formatting - the namespace indenting can be turned off in the options.

Unfortunately the indent engine is not compatible with the formatting engine - the formatting/indenting layer needs much work, but I don't know when we'll do it.

But y, when the indenting is set to none or auto the cut & paste behaviour should be different - and that's fixed. (will be in the 4.2 release I guess - I don't know if we put it into 4.0)