How does ''surround'' work?

This is a discussion on How does ''surround'' work? within the Delphi forums in Programming Languages category; I have this three indented lines: for i := 1 to 10 do begin DoSomething; end {for}; If I select them, and right-click ''surround tryf'', I get this: try for i := 1 to 10 do begin DoSomething; end {for}; finally end; The selected code indentation is increased, which is correct, but the try/finally/end is not indented at the former code indentation. Is that the intended behaviour? I would have expected this: try for i := 1 to 10 do begin DoSomething; end {for}; finally end; Chris...

Go Back   Application Development Forum > Programming Languages > Delphi

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-06-2008, 12:02 PM
Chris
Guest
 
Default How does ''surround'' work?

I have this three indented lines:

for i := 1 to 10 do begin
DoSomething;
end {for};

If I select them, and right-click ''surround tryf'', I get this:

try
for i := 1 to 10 do begin
DoSomething;
end {for};

finally
end;

The selected code indentation is increased, which is correct, but the
try/finally/end is not indented at the former code indentation. Is that the
intended behaviour?

I would have expected this:

try
for i := 1 to 10 do begin
DoSomething;
end {for};
finally
end;

Chris


Reply With Quote
  #2  
Old 08-07-2008, 05:53 AM
Peter Below (TeamB)
Guest
 
Default Re: How does ''surround'' work?

Chris wrote:

> I have this three indented lines:
>
> for i := 1 to 10 do begin
> DoSomething;
> end {for};
>
> If I select them, and right-click ''surround tryf'', I get this:
>
> try
> for i := 1 to 10 do begin
> DoSomething;
> end {for};
>
> finally
> end;
>
> The selected code indentation is increased, which is correct, but the
> try/finally/end is not indented at the former code indentation. Is
> that the intended behaviour?


The resulting alignment is a bit random <g>, the template engine is not
quite up to the task here. If you select comlete lines you get what you
observered, with the try..finally positioned in column 0. If you start
the selection on the "f" of the for and extend it to the semicolon
after the end comment you get something a bit closer to what one would
expect: the finally end is aligned on the old column of the for but the
try ends up directly above the for, so one indentation level to far to
the right.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
Reply With Quote
  #3  
Old 08-07-2008, 07:08 AM
Gerrit Beuze
Guest
 
Default Re: How does ''surround'' work?

Hello Chris,

> The selected code indentation is increased, which is correct, but the try/finally/end is not indented at the former code
> indentation. Is that the intended behaviour?



As Peter mentioned : " The resulting alignment is a bit random "

If you want better surround templates, check ModelMaker Code Explorer:
http://www.modelmakertools.com/code-explorer/index.html

This allows controlling the indent per template (and even unindent the template)
allows surrounds in a single line (FreeAndNil(..), Format(...)
and has two dedicated surrounds:

try finally wizard: this inserts finalization code based on the code before try.
block wizard: this surrounds a selection with a beginend bloc, determining
the indent automatically.

Both and several other "minor" features are demo-ed in this movie:
http://modelmakertools.com/movies/beyond-templates.htm
The try finally wizard is at about 3/4...


Gerrit Beuze
ModelMaker Tools


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:50 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.