OmniSharp / omnisharp-server

HTTP wrapper around NRefactory allowing C# editor plugins to be written in any language.
http://www.omnisharp.net
MIT License
380 stars 97 forks source link

Detected overlapping changes on Code Format #90

Open d12frosted opened 10 years ago

d12frosted commented 10 years ago

Hello nosami,

It's me again. And again with formatting problems. Everything works fine except code-format. It was working few moments ago and then just started to push strange messages. I thought something went wrong with my settings of OmniSharpServer, so I totally removed it, cloned clean project from your repository, and installed clean copy. Then started the server and found the same error. Everything works except code-format ^^.

Here is output from OmniSharpServer:

00065930 System.InvalidOperationException: Detected overlapping changes [TextReplaceAction: Offset=271, RemovalLength=4, NewText=        ]/[TextReplaceAction: Offset=270, RemovalLength=5, NewText=
        ]
at ICSharpCode.NRefactory.CSharp.FormattingChanges.ApplyChanges (int,int,System.Action`3<int, int, string>,System.Func`4<int, int, string, bool>) <0x00223>
at ICSharpCode.NRefactory.CSharp.FormattingChanges.ApplyChanges () <0x000f7>
at ICSharpCode.NRefactory.CSharp.CSharpFormatter.InternalFormat (ICSharpCode.NRefactory.Editor.IDocument) <0x00057>
at ICSharpCode.NRefactory.CSharp.CSharpFormatter.Format (string) <0x0003b>
at OmniSharp.CodeFormat.CodeFormatHandler.Format (OmniSharp.CodeFormat.CodeFormatRequest) <0x0006f>
at OmniSharp.CodeFormat.CodeFormatModule/<CodeFormatModule>c__AnonStorey0.<>m__0 (object) <0x0003b>
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,System.Func`2<object, object>,object) <0x00085>
at Nancy.Routing.Route/<>c__DisplayClass4.<Wrap>b__3 (object,System.Threading.CancellationToken) <0x00108>

I can't understand what's going on. It doesn't work with any file of my current project. But it works well with files from other projects (if I start server with their sln file). Any ideas?

mikavilpas commented 10 years ago

Hmm, interesting! Could your current project be special in some way? What version of the .net framework does it use, for example.

What platform and editor plugin are you using?

d12frosted commented 10 years ago

Currently I am working on Unity3d project on C#. I have next configurations:

I did some tests. It really doesn't work only with few files in current project. I even tried to get clean copy of out Unity3d project, then generated brand new MyGame.sln file (Mono project). But problem still bother me.

d12frosted commented 10 years ago

Oh. Just found the code that fails OmniSharp to format whole buffer.

    int[] my_ints =
    {
        1,
        2,
        3,
        4
    };

This is not exactly the code I use, but I checked – OmniSharp or NRefactory fails to format this code. And yes, this code

int[] my_ints = { 1, 2, 3, 4 };

is formatted without any problems. :)

Updated

More funny things. I am using Allman intending style.

first

This code:

    int[] my_ints =
        { 1,
          2,
          3,
          4 };

is formatted into

    int[] my_ints =
        { 1,
            2,
            3,
            4
        };

second

This code

    int[] my_ints =
        {
            1,
            2,
            3,
            4
        };

Is formated to itself (no error occurs).

third

But this one

    int[] my_ints =
    {
        1,
        2,
        3,
        4
    };

can't be formatted :)

nosami commented 10 years ago

I can replicate the bug. I don't have any idea what the problem is yet though. I'll take another look when I get chance.

Thanks

d12frosted commented 9 years ago

Just a funny update. /codeformat can't format Program.cs file :D Actually this is the code that causes errors:

var options = new OptionSet
        {
            {
                "s|solution=", "The path to the solution file",
                s => solutionPath = s
            },
            {
                "p|port=", "Port number to listen on",
                (int p) => port = p
            },
            {
                "c|client-path-mode=", "The path mode of the client (Cygwin, Windows or Unix)",
                c => clientPathMode = c
            },
            {
                "v|verbose=", "Output debug information (Quiet, Debug, Verbose)",
                v => verbosity = v != null
                                    ? (Verbosity)Enum.Parse(typeof(Verbosity), v)
                                    : Verbosity.Debug
            },
            {
                "h|help", "Show this message and exit",
                h => showHelp = h != null
            },
            {
                "config=", "The path to the server config.json file",
                path => configLocation = path
            }
        };

The error is similar.

nosami commented 9 years ago

Yeah. Btw.... this project is hopefully gonna be superceded by this soon https://github.com/OmniSharp/omnisharp-roslyn :)

d12frosted commented 9 years ago

Oh. Haven't noticed it before. Gonna check it out.