Recent

Author Topic: [identifier addition from suggestion list] Please your Opinions about  (Read 7365 times)

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
function func_():type
begin
           func_returnsomething(type,othertype);
          ^ <---if you start typing just before the identifier
          | the suggestions list will open an item will picked with enter and the the new item will take the place of [ func_dosomething ]!! the parenthesis with the parameteres remains intact (happens often because ctrl+ arrow always points at the start of a word)
end;
the ideal will be
if the selected new identifier has parameters then [ func_dosomething ] should be enclosed in the parenthesis as the first parameter that equals the type
if the selected new identifier has no parametres then a space should be added between the two identifiers
in any case it would be nice if this feature added and the [ func_dosomething ] stays in place

======================================
Is it possible to have your opinions on this?
« Last Edit: October 25, 2014, 11:56:36 am by Never »
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • I like bugs.
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #1 on: October 25, 2014, 02:46:01 pm »
Thanks for opening the discussion here. The bug tracker was a wrong place for it.
The report:
  http://bugs.freepascal.org/view.php?id=26891

IMO Delphi and lazarus are the only IDEs that do this one right. Now you want to destroy it.
Both thumbs down from me. Sorry.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #2 on: October 25, 2014, 02:59:38 pm »
excuse me but i do not understant what is right so i will try to screen capture the behavior mabe my english are not good and replay here
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #3 on: October 25, 2014, 03:00:13 pm »
Just on the code completion (ctrl + space):

I would also very much advice to keep current behaviour. That includes not to even change the behaviour by option.

However I could see ways to have it added.

1) as separate package, invoking a "special code completion) that can be installed, and mapped to any key wanted.

This can be provided by anyone who want, and go to CCR. So if you want to do that, or if you find someone, that is fine.

2) Either as external package, or maybe as build in / partial build in.
Allow to finish code completion by another special key (e.g. when the drop down is open, press "ctrl-(" ), and that will trigger the desired behaviour. (It would never be the default)

This one may be very hard to do, as it likely needs a lot of callbacks between different packages, in order to make sure, that no code ends up in the wrong place)

3) Allow to invoke a pas-script macro when code completion finishes. Then everyone can get whatever they like.


-------------------
For any of them a volunteer would be needed.


Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #4 on: October 25, 2014, 03:39:50 pm »
well just made a recording have a look if you please
[ http://youtu.be/IUFvcQ9pKtU ]

Edit*** :@Martin_fr there is nothing wrong with ctrl+space and autocompleteion works nice but it can be better
Quote
the ideal will be
if the selected new identifier has parameters then [ func_dosomething ] should be enclosed in the parenthesis as the first parameter that equals the type
if the selected new identifier has no parametres then a space should be added between the two identifiers
in any case it would be nice if this feature added and the [ func_dosomething ] stays in place
« Last Edit: October 25, 2014, 03:44:13 pm by Never »
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • I like bugs.
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #5 on: October 25, 2014, 04:24:04 pm »
well just made a recording have a look if you please
[ http://youtu.be/IUFvcQ9pKtU ]

Yes, the code completion works exactly as it should. When you select something from the list, the original identifier is replaced. The other IDEs do it wrong. For example Eclipse and NetBeans leave the old string there and you must explicitly delete it. Irritating!
Your example is bad, typically you would select an existing function or method from the list.
Question: if you did NOT want to replace the identifier, why did you press Ctrl-Space?
Did it happen "by accident" as you explained in the bug report?
Do you seriously propose that we should change the IDE's behavior because you happen to press a certain key combination "by accident"?

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #6 on: October 25, 2014, 04:28:51 pm »
i stated very clear that i did not press ctrl+space by accident but because i was expecting the proposed behavior
Quote
the ideal will be
if the selected new identifier has parameters then [ func_dosomething ] should be enclosed in the parenthesis as the first parameter that equals the type
if the selected new identifier has no parametres then a space should be added between the two identifiers
in any case it would be nice if this feature added and the [ func_dosomething ] stays in place

Quote
ps/ctrl+space pressed on porpouse from me because expected the previus funtion (inttostr) to be encolsed inside the parenthesis of writeln as a parameter and expected a result in this case like this [writeln(inttostr(x))<--cursor here after completion]

ps/ if this is going to be personal i prefer to stop the discussion here
 please show the same i respect i show to your self
sarcasm and irony are not expressed from me in anyway to anyone .
even if had to state the same things again and  again and again and again.....
« Last Edit: October 25, 2014, 04:32:42 pm by Never »
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1248
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #7 on: October 25, 2014, 04:50:54 pm »
As I understand this,  Never is NOT complaining that the function IntToStr was replaced,  instead he is suggesting that the list  of entries in the dropdown should be filtered for functions with the correct parameters.   In the example, as function with an integer parameter was replaced with one expecting a string.

So,  the replacement functionality is not at issue, or at least, not as I understand this.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #8 on: October 25, 2014, 04:53:27 pm »
"better" is (in this case) subjective.

Also I do not think that there is just one correct way for code completion to work. In that way "Never"'s post is a valid feature request.

However this feature is "Enclose identifier in function call", and it is a separate feature. So it should not change existing features.


Btw, try this. Define this Macro( http://wiki.lazarus.freepascal.org/IDE_Window:_Editor_Macros ), and assign it to a keycombo of your choice.

Code: [Select]
var
  p1: TPoint;
  s1: string;
begin
  p1 := Caller.LogicalCaretXY;
  s1 := Caller.Lines[p1.y - 1];
  if ( (p1.x = 1) or (s1[p1.x-1] = ' ') ) and (p1.x < length(s1)) and (s1[p1.x] <> ' ') then begin
    ecChar('(');
    ecWordEndRight;
    ecChar(')');
    Caller.LogicalCaretXY := p1;
  end;
  ecIdentCompletion;
end.

It can not detect, if you choose a function or else, so this is for "function" only!

*IF" right at the start of a word (and only then), it encloses the word in (), and then opens completion.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • I like bugs.
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #9 on: October 25, 2014, 05:19:39 pm »
A new command with a new shortcut would be ok.
I believe it would be accepted as a package or as integrated in IDE.

Filtering the code completion entries for functions with the correct parameters is part of the new feature if I understand right.
The original function/method should not be replaced but the completion list should follow its return type.
I admit it can be a useful feature but it should not replace the existing code completion.

I don't believe anybody objects such a new feature, but as Martin wrote it needs a volunteer to implement.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #10 on: October 25, 2014, 05:34:51 pm »
i did the macro but i'm not able to notice other than the usual drop down cimpletion box to appear

i'm very sorry for this is, the first time i use macros and probably i do not do it right

Quote
It can not detect, if you choose a function or else, so this is for "function" only!
parameters are in procedures too

Edit:*** if i underst you correct @Martin_fr not only for functions but for variables,constants too
ex:  writting--> var_someint press ctrl+left inttostr{press enter}var_someint will produce inttostr(var_someint );<--cursor here as long as the var_someint  match the type of inttostr({param})
if more than on parameters there then   mach  the first equal type param
if there are no paramaters or no mach do nothing or (this could be a choice) add  a space bettween previus function and the new one to produce  strtoint( ){<--cursor here} var_someint
« Last Edit: October 25, 2014, 05:49:59 pm by Never »
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #11 on: October 25, 2014, 06:58:10 pm »
@Mike.Cornflake i'm sorry i didn't respond to your message earlier
yes i'm not complaining at all
i think @Martin_fr got it right
thank you @Mike.Cornflake
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #12 on: October 25, 2014, 07:09:57 pm »
i did the macro but i'm not able to notice other than the usual drop down cimpletion box to appear

Did you assign a key-combo to the macro?
If you want ctrl space, then you need to un-assign that first from the normal completion.


Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #13 on: October 25, 2014, 07:27:06 pm »
Code: [Select]
var
  p1: TPoint;
  s1: string;
begin
  p1 := Caller.LogicalCaretXY;

  s1 := Caller.Lines[p1.y - 1];
   // showmessage(s1);
   showmessage(inttostr(p1.x)+'  ' + s1[p1.x-1]);
  if ( (p1.x = 1) or (s1[p1.x-1] <> '') ) and (p1.x < length(s1)) and (s1[p1.x] <> ' ') then begin
    ecChar('(');
    //ecWordEndRight:= length(s1);
    ecLineEnd;

    ecChar(')');
    p1.x:=p1.x+1;
    Caller.LogicalCaretXY := p1;
  end;
  ecIdentCompletion;
end.

did my best to fix it to reflect the behavior as i could
Edit***: put it on shift+1
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5635
    • wiki
Re: [identifier addition from suggestion list] Please your Opinions about
« Reply #14 on: October 25, 2014, 08:28:34 pm »
Good to hear it works ;)

Btw, here is an overview of what code/identifier completion can currently do: http://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools
(Most people do not know all of the possibilities)

Your feature request is still valid, but until someone volunteers to do something, there are a lot of good existing features, that can help.