This is a migrated thread and some comments may be shown as answers.

Unwante empty lines

4 Answers 69 Views
Refactorings
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ManniAT
Top achievements
Rank 2
ManniAT asked on 23 Nov 2010, 01:51 PM
Hi,

after one of the latest releases (I'm not sure which - sorry) JC started to enter empty lines.
Assume the following code:
Snippet created with CBEnhancer
public class PriceGrabber {
    private struct PriceValues {
        public double dCurPrice;
        public double dRoundAdd;
        public int nRoundDigits;
        public string strCurSkuID;
    }
    private class ThreadCounter {
        public int m_nThreadCount;
    }
    private static ThreadCounter m_TC = new ThreadCounter(); //HERE I CHANGE
    public const int m_nDaysToCheck = 1;
    #region LastErr
    private static string m_strLastErr;
    public static string LastErr {
        get { return m_strLastErr; }
        set { m_strLastErr = value; }
    }
    #endregion
When I change my code and remove / retype the semicolon after "new ThreadCounter()" I get:
Snippet created with CBEnhancer
private class ThreadCounter {
    public int m_nThreadCount;
}

private static ThreadCounter m_TC = new ThreadCounter();
public const int m_nDaysToCheck = 1;
As you can see a newline has been added after the class.
That is not "too bad" - but my real problem comes when I remove / replace the curling bracket at the end of
the "PriceGrabber" class definition (or choose JC - Format code).
What I get is:
Snippet created with CBEnhancer
public class PriceGrabber {
        private struct PriceValues {
            public double dCurPrice;
            public double dRoundAdd;
            public int nRoundDigits;
            public string strCurSkuID;
        }

        private class ThreadCounter {
            public int m_nThreadCount;
        }

        private static ThreadCounter m_TC = new ThreadCounter();
        public const int m_nDaysToCheck = 1;
        #region LastErr
        private static string m_strLastErr;

        public static string LastErr {
            get { return m_strLastErr; }
            set { m_strLastErr = value; }
        }

        #endregion
You see - every (almost) "declaration block" like "private struct PriceValues" (which is the exception - no blank line in front)
or "public static string LastErr" gets added blank line before and after it.
Especially when I have a lot of properties in a class this blowing up my code a lot.
For every propert I want (enter - use):
Snippet created with CBEnhancer
#region LastErr
private static string m_strLastErr;
public static string LastErr {
    get { return m_strLastErr; }
    set { m_strLastErr = value; }
}
#endregion
And what I get is:
Snippet created with CBEnhancer
#region LastErr
private static string m_strLastErr;

public static string LastErr {
    get { return m_strLastErr; }
    set { m_strLastErr = value; }
}

#endregion

I found no way to "disable" these blank lines. I also found no rule for this in settings.
Neither in VS (which by the way doesn't add such lines if I don't use JC) nor in any of the JC settings.

Manfred

4 Answers, 1 is accepted

Sort by
0
Deyan Varchev
Telerik team
answered on 26 Nov 2010, 04:25 PM
Hello Manfred,

 Thanks for reporting this. These glitches are side effects from the auto-formatting that JustCode does when you enter either semi-colon ( ; ) or closing brace ( } ). Both of these cause automatic reformat of the parts of the code and thus insert some empty lines.
 Currently those empty lines are inserted by JustCode's formatter on order to bring better code readability. We haven't exposed specific settings to control them but for the next release we have plans to greatly improve our current formatting and those will be included there.
 For now as a temporary solution you can disable auto-formatting in semi-colon or closing brace from JustCode's options - JustCode | Options | General | Typing Assistance -> Format on semicolon & Format on closing brace

All the best,
Deyan
the Telerik team
Browse the videos here>> to help you get started with JustCode
0
ManniAT
Top achievements
Rank 2
answered on 27 Nov 2010, 03:35 PM
Hi Deyan,

thank you for your answer.
Unfortunately the "temporary workaround" isn't useable for me because I need (want) to reformat.
Or in other words - 99% of formatting is excatly what I want - so I don't wann miss this for just that one unwanted thing.

It would be great to have an option about this empty lines - and meanwhile (my temporary workaround) I have to accept it :)

To finis this - I love JC - and I almost can't remeber how I worked without it before!

Manfred
0
ManniAT
Top achievements
Rank 2
answered on 27 Nov 2010, 10:46 PM
I just worked on my laptop - and there the empty lines do NOT appear.
I double checked setting (JC and VS) - both are the same as on my desktop with the problem.
So I guess it has something to do with "Learn style from code".

Is there a way to edit or at least clear the "learned things"?

Manfred
0
Deyan Varchev
Telerik team
answered on 03 Dec 2010, 08:35 PM
Hi Manfred,

 Sorry for the late response. Currently there is no UI allowing you to reset your formatting settings to the default ones. However you can manually do that by either deleting or renaming the code style settings file that JustCode uses to store the settings. It's located in the following folder:
 C:\Users\<Your user account>\AppData\Roaming\JustCode
The file that you need to delete/rename is settings.justcode. I recommend you to rename it to something like settings.justcode.bak so that you can revert back to it if something goes wrong. Have in mind that all instances of Visual Studio need to be stopped before you do that. 

 I hope that this will help.
 
Regards,
Deyan
the Telerik team
Browse the videos here>> to help you get started with JustCode
Tags
Refactorings
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Deyan Varchev
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or