[MonoDevelop] New code formatter joins line to aggressively
mkrueger at novell.com
Fri Sep 11 16:28:28 EDT 2009
> * Apart from "Format document", there should also be a "Format
> selection". The latter one would operate on the current line only, if
> there is no selection.
Difficult to do, I could do something like format current member/block
> * It joins lines way to aggressively.
> For example, this manually formatted code (best viewed in monospace...):
> ICriteria criteria =
> .Add( Restrictions.Eq("Name", connectionName) );
> becomes this unreadable thing:
> ICriteria criteria = session.CreateCriteria
> (typeof(RegisterRequest)).CreateCriteria ("Connection").Add
> (Restrictions.Eq ("Name", connectionName));
I'm currently working on improving the on the fly formatter a bit. It
preserves custom spaces but has problems with some settings. This
algorithm could then be used for format document.
> Maybe it shouldn't join lines at all. Rather, if a statement is
> manually divided over several lines, it should probably remain on as
> many lines with all lines except the first indented one more step than
> the first line. Possibly, if it is inside parentheses then perhaps the
> subsequent lines should align with the parentheses, like they did in
> the MD 2.0's indentation mode:
> var recent_not_infinite_enddate =
> Restrictions.And(Restrictions.Ge("EndDate", earliestChangeTime),
> Restrictions.Lt("EndDate", DateTime.MaxValue));
> Now.... another question is: Should it wrap lines that are too long?
I can need help/ideas for improving the format algorithm. I've two
options doing the merge of blank lines/comments for example. I'm not
100% sure which is better. The alignment is part of this.
Wrap lines that are too long - artifically ? Could be done, but I think
it's nonsense having something like the '80 chars' limit (did I mention
that I work with a 28" wide screen display ?).
More information about the Monodevelop-list