Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-07

Code-Template issue - duplicating text

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi

I created a while back a code template to fix the case of the word Result. eg: result --> Result

[ Yes, I'm full of sh*t ]

Anyway, here is the code template as Lazarus wrote it in the .dci file.

=========[ lazarus.dci ]============
[result | Fix case - Result]
$(AttributesStart)
AutoOnWordEnd=true
$(AttributesEnd)
Result
============================

Now look at the animated gif (attached). You might have to view it in your Web Browser to see the animation and to get the full effect of the issue.

writeln('[DEBUG]Result = ' + Result)
^
cursor is here

As soon as I press the spacebar while the cursor is between the ']' and the 'R' characters, then Lazarus duplicates the word "Result". Is this a code templates bug, or did I define my code-template incorrectly? And every time I press the spacebar, another duplicate occurs.... Weird one!

Lazarus 0.9.27 rUnknown FPC 2.2.5 i386-linux-gtk 2 (beta) Lazarus revision is around 2009-06-12 in trunk.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ -------------- next part -------------- A non-text attachment was scrubbed... Name: bug.gif Type: image/gif Size: 8810 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090709/ff24e51f/attachment.gif>

Reply by email

Reenen Laurie
to Graeme Geldenhuys

Way off-topic here:

I have no idea what your problem is... but my firefox (3.5) favicon (the small icon that shows next to the addressbar and in tab)... had a minute version (16x16) of the animated gif... animating. You can really only see the cursor...

I think that is SO cool... why don't people use animated gif's for favicon's more often? How about an animated Lazarus Icon? I can see a paw indentation being created as an icon... Although we have the gear one at the moment... maybe it's eyes flashes?

Anyway, maybe I'm just being hyper.

Regards,
-Reenen

2009/7/9 Graeme Geldenhuys :

Show quoted text 49 lines
Hi I created a while back a code template to fix the case of the word Result. eg: ?result ?--> ?Result [ ?Yes, I'm full of sh*t ?] Anyway, here is the code template as Lazarus wrote it in the .dci file. =========[ lazarus.dci ]============ [result | Fix case - Result] $(AttributesStart) AutoOnWordEnd=true $(AttributesEnd) Result ============================ Now look at the animated gif (attached). You might have to view it in your Web Browser to see the animation and to get the full effect of the issue. ?writeln('[DEBUG]Result = ' + Result) ? ? ? ? ? ? ? ? ?^ ? ? ? ? ? cursor is here As soon as I press the spacebar while the cursor is between the ']' and the 'R' characters, then Lazarus duplicates the word "Result". ?Is this a code templates bug, or did I define my code-template incorrectly? And every time I press the spacebar, another duplicate occurs.... Weird one! Lazarus 0.9.27 rUnknown FPC 2.2.5 i386-linux-gtk 2 (beta) Lazarus revision is around 2009-06-12 in trunk. Regards, ?- Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions.

Reply by email

Martin Friebe
to Graeme Geldenhuys: Hi I created a while back a code template to fix the case of the word Result. eg: result…

It's probably a bug.
Report it and I can have a look. (or someone, but I am willing, and I probably broke it)

IIRC there the code template, once called, searches the text for the template identifier, so it can repalce it. Seems that if you are at the start of token, it does not find it.
(It should find it, since it got invoked / or alternatively, it should not get invoked, if decission was not to work if at start of token. IMHO it should work)

does it also happen, if the caret is in the middle of your token?

Best Regards
Martin

Graeme Geldenhuys wrote 50 lines
Hi I created a while back a code template to fix the case of the word Result. eg: result --> Result [ Yes, I'm full of sh*t ] Anyway, here is the code template as Lazarus wrote it in the .dci file. =========[ lazarus.dci ]============ [result | Fix case - Result] $(AttributesStart) AutoOnWordEnd=true $(AttributesEnd) Result ============================ Now look at the animated gif (attached). You might have to view it in your Web Browser to see the animation and to get the full effect of the issue. writeln('[DEBUG]Result = ' + Result) ^ cursor is here As soon as I press the spacebar while the cursor is between the ']' and the 'R' characters, then Lazarus duplicates the word "Result". Is this a code templates bug, or did I define my code-template incorrectly? And every time I press the spacebar, another duplicate occurs.... Weird one! Lazarus 0.9.27 rUnknown FPC 2.2.5 i386-linux-gtk 2 (beta) Lazarus revision is around 2009-06-12 in trunk. Regards, - Graeme - ------------------------------------------------------------------------ ------------------------------------------------------------------------ -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin Friebe
to Martin Friebe

Actually, just thinking. IMHO a template should be triggered, if you are at the end of the token?, so pressing space, *before* the "return" should probably not again it is still broken.

tryc|f ctrl-j

executes the trycf template (as tryc was enough to identify it "tryc| ctrl-j"

but the "f" is kept in the text....

Martin Friebe wrote 55 lines
It's probably a bug. Report it and I can have a look. (or someone, but I am willing, and I probably broke it) IIRC there the code template, once called, searches the text for the template identifier, so it can repalce it. Seems that if you are at the start of token, it does not find it. (It should find it, since it got invoked / or alternatively, it should not get invoked, if decission was not to work if at start of token. IMHO it should work) does it also happen, if the caret is in the middle of your token? Best Regards Martin Graeme Geldenhuys wrote: > Hi > > I created a while back a code template to fix the case of the word > Result. eg: result --> Result > > [ Yes, I'm full of sh*t ] > > Anyway, here is the code template as Lazarus wrote it in the .dci file. > > =========[ lazarus.dci ]============ > [result | Fix case - Result] > $(AttributesStart) > AutoOnWordEnd=true > $(AttributesEnd) > Result > ============================ > > > Now look at the animated gif (attached). You might have to view it in > your Web Browser to see the animation and to get the full effect of > the issue. > > writeln('[DEBUG]Result = ' + Result) > ^ > cursor is here > > As soon as I press the spacebar while the cursor is between the ']' > and the 'R' characters, then Lazarus duplicates the word "Result". > Is this a code templates bug, or did I define my code-template > incorrectly? And every time I press the spacebar, another duplicate > occurs.... Weird one! > > Lazarus 0.9.27 rUnknown FPC 2.2.5 i386-linux-gtk 2 (beta) > Lazarus revision is around 2009-06-12 in trunk. >

Reply by email

Graeme Geldenhuys
to Martin Friebe: It's probably a bug. Report it and I can have a look. (or someone, but I am willing, and I
Martin Friebe wrote
Report it and I can have a look. (or someone, but I am willing, and I probably broke it)

OK, will to so tomorrow from work.

does it also happen, if the caret is in the middle of your token?

I don't think it does, but I'll double check tomorrow.

Regards,
- Graeme -

________________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Martin Friebe: Actually, just thinking. IMHO a template should be triggered, if you are at the end of…
Martin Friebe wrote 8 lines
Actually, just thinking. IMHO a template should be triggered, if you are at the end of the token?, so pressing space, *before* the "return" should probably not is the exact same behaviour that I expected. Plus the duplication of the text is a odd behaviour too. tryc|f ctrl-j executes the trycf template (as tryc was enough to identify it "tryc| ctrl-j"

Not that the code template I use is NOT meant to be trigger with ctrl-j, it is one of those automatic triggers, when a new word is started (pressing the Spacebar or Enter at the end of the token.

Regards,
- Graeme -

________________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Martin Friebe
to Graeme Geldenhuys

ok, I have gone back to 0924 => the problem did already exist.

1) It is perfectly fine, even desirable that using ctrl-j you may have a partial typed template-identifier (as long as it uniquely identifies the template

example: trycf
you can type: tryc ctrl-j

as trycf is the only template starting with tryc this is fine and works

1a) ctrl-j in the middle of a tmpl identifier
example, type:
trycf cursor-left ctrl-j
or
tryc|f ctrl-j

Works too => but currently leads to an extra "f" at the end of the inserted template

This can be fixed, it is no harm => Personally I don't see the application...

2) completing a keyword with space, return or other word-end-char This can only work, if the full template identifier has been entered, typing space. In the return example below, typing "ret" + space, would correctly do nothing

But this currently also works, if you press space anywhere within the word => imho this is wrong => space/return, should only work, if you are at the end of the template identifier

Graeme Geldenhuys wrote 18 lines
Martin Friebe wrote: > Actually, just thinking. IMHO a template should be triggered, if you > are at the end of the token?, so pressing space, *before* the > "return" should probably not trigger at all. That is the exact same behaviour that I expected. Plus the duplication of the text is a odd behaviour too. > tryc|f ctrl-j > > executes the trycf template (as tryc was enough to identify it > "tryc| ctrl-j" Not that the code template I use is NOT meant to be trigger with ctrl-j, it is one of those automatic triggers, when a new word is started (pressing the Spacebar or Enter at the end of the token.

Reply by email

Graeme Geldenhuys
to Martin Friebe
Martin Friebe wrote
But this currently also works, if you press space anywhere within the word => imho this is wrong => space/return, should only work, if you are at the end of the template identifier

That's correct, and exactly my point. :-) We agree on the behaviour.

Just to reiterate my problem. Have code as show below:

writeln('[DEBUG]|Result = ' + Result)
^
cursor is here the '|' sign.

In my case the word 'Result' was already spelt correctly, exactly as shown above. I simply wanted to place a space between '..BUG]' and 'Result', but when I pressed the spacebar, code-completion got triggered (and it shouldn't have) [problem #1]. And when it got triggered, it duplicated the token which it shouldn't have [problem #2].

So yes I fully agree with you, the code-completion via automatic triggers (ending the token with a space or Enter) should ONLY occur when you have completely written the token and only trigger AFTER the token. Not inside or in-front of the token - like what happened to me.

I'll create a bug report for this (as I described it above): "Code-completion for automatic triggers should only occur after the token"

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Martin Friebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote 12 lines
Martin Friebe wrote: > But this currently also works, if you press space anywhere within the > word => imho this is wrong => space/return, should only work, if you > are at the end of the template identifier That's correct, and exactly my point. :-) We agree on the behaviour. Just to reiterate my problem. Have code as show below: writeln('[DEBUG]|Result = ' + Result) ^ cursor is here the '|' sign.

Check the latest SVN. this should behave better now

Reply by email