# Water editor try/finally block default formatting

**URL:** https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963
**Category:** Water
**Tags:** hydrogene
**Created:** [November 16, 2018, 4:05pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963 "2018-11-16T16:05:16Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Chris2](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chris2/32/8714_2.png) [@Chris2](https://talk.remobjects.com/u/Chris2)
#### Post date: [November 16, 2018, 4:05pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/1 "2018-11-16T16:05:16Z")

</div>

In Water C# code, when the file is reformatted (Edit -\> Reformat File), I think the finally blocks are indented incorrectly (at least different than the catch blocks).

This is what I get after a reformat:

```auto
            try
            {
                
            }
            catch(Exception e)
            {
                
            }
            
            try
            {
                
            }
            finally
                {
                
                }
```

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [November 16, 2018, 4:19pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/2 "2018-11-16T16:19:56Z")

</div>

Does that happen in any context? or can you give me a complete file as tetscase? thanx!

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [November 16, 2018, 4:20pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/3 "2018-11-16T16:20:00Z")

</div>

Thanks, logged as bugs://81437

---

<div class="post-metadata">

### Author: ![Chris2](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chris2/32/8714_2.png) [@Chris2](https://talk.remobjects.com/u/Chris2)
#### Post date: [November 16, 2018, 4:56pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/4 "2018-11-16T16:56:39Z")

</div>

Yes, seems to happen in any context. The indenting happens correctly initially while typing and adding the curly braces, but if something signals a reformat, or if you choose it from the edit menu, the finally curlys get indented more.

Water test case:

File -\> New Project -\> Echos -\> Winforms

Then modify Program.cs:

```auto
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace WindowsApplication
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += OnThreadException;
            using (MainForm lMainForm = new MainForm())
            {
                Application.Run(lMainForm);
            }
            
            try
            {
                // try something
            }
            catch (Exception e)
            {
                // oops
            }
            
            try
            {
                // do something else
            }
            finally
            {
                // done with something else
            }
            
        }

        void OnThreadException(Object sender, ThreadExceptionEventArgs e)
        {
            System.Windows.Forms.MessageBox.Show(e.Exception.Message);
        }
    }
}
```

Then go to Edit -\> Reformat File, and you will get this:

```auto
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace WindowsApplication
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += OnThreadException;
            using (MainForm lMainForm = new MainForm())
            {
                Application.Run(lMainForm);
            }
            
            try
            {
                // try something
            }
            catch (Exception e)
            {
                // oops
            }
            
            try
            {
                // do something else
            }
            finally
                {
                    // done with something else
                }
            
        }

        void OnThreadException(Object sender, ThreadExceptionEventArgs e)
        {
            System.Windows.Forms.MessageBox.Show(e.Exception.Message);
        }
    }
}
```

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [November 17, 2018, 12:13am UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/5 "2018-11-17T00:13:10Z")

</div>

glad the editing part is fine, coz that’s my code in water ;). the reformat is done my the manager project system, and that’s out of _my_ hand to fix or worry about ;).

ps: some new editor features in 2345. let me know what you think!

---

<div class="post-metadata">

### Author: ![Chris2](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chris2/32/8714_2.png) [@Chris2](https://talk.remobjects.com/u/Chris2)
#### Post date: [November 17, 2018, 3:10am UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/6 "2018-11-17T03:10:15Z")

</div>

I can’t seem to figure out what the new features are. Hints please?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [November 17, 2018, 11:41am UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/7 "2018-11-17T11:41:24Z")

</div>

for example, type “if”.

---

<div class="post-metadata">

### Author: ![Chris2](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chris2/32/8714_2.png) [@Chris2](https://talk.remobjects.com/u/Chris2)
#### Post date: [November 17, 2018, 12:07pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/8 "2018-11-17T12:07:20Z")

</div>

Nice!!!

---

<div class="post-metadata">

### Author: ![viktoriad](https://talk.remobjects.com/user_avatar/talk.remobjects.com/viktoriad/32/11148_2.png) [@viktoriad](https://talk.remobjects.com/u/viktoriad)
#### Post date: [November 19, 2018, 9:46am UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/9 "2018-11-19T09:46:55Z")

</div>

Hello,  
I couldn’t reproduce the problem with reformatting here. Two weeks ago I had that bug logged, and I fixed it on Nov 9. So if you have the earlier build, could you please download latest and check with it. If you’ve got recent up-to-date elements, please give me some video on how you are reproducing the problem.  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![Chris2](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chris2/32/8714_2.png) [@Chris2](https://talk.remobjects.com/u/Chris2)
#### Post date: [November 19, 2018, 4:16pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/10 "2018-11-19T16:16:24Z")

</div>

Hi,

In the latest build it isn’t happening with just comments inside the finally block, so you probably aren’t seeing the problem there.

Try following the steps in my original post, but paste this in instead:

```auto
            try
            {
                Application.Run();
            }
            catch (Exception e)
            {
                Application.Run();
            }
            
            try
            {
                Application.Run();
            }
            finally
            {
                Application.Run();
            }
```

After going to Edit -\> Reformat File the final curly brace will indent itself too far. Curiously enough, the first curly brace in the finally block stays put now.

Let me know if that doesn’t show the problem for you and I will try to figure out how to do a video of some sort.

---

<div class="post-metadata">

### Author: ![viktoriad](https://talk.remobjects.com/user_avatar/talk.remobjects.com/viktoriad/32/11148_2.png) [@viktoriad](https://talk.remobjects.com/u/viktoriad)
#### Post date: [November 19, 2018, 5:35pm UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/11 "2018-11-19T17:35:30Z")

</div>

Yes, reproduced with your testcase now.  
Thanks.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [November 20, 2018, 9:25am UTC](https://talk.remobjects.com/t/water-editor-try-finally-block-default-formatting/17963/12 "2018-11-20T09:25:54Z")

</div>

bugs://81437 got closed with status fixed.
