After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 578599 - ipython_view completion feature has a bug
ipython_view completion feature has a bug
Status: RESOLVED OBSOLETE
Product: accerciser
Classification: Applications
Component: core
unspecified
Other All
: Low normal
: ---
Assigned To: Accerciser Developers
Accerciser Developers
Depends on:
Blocks:
 
 
Reported: 2009-04-10 13:22 UTC by lasagna davide
Modified: 2021-05-17 15:43 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
lasagna davide's solution for completion feature (1.17 KB, patch)
2011-07-04 22:55 UTC, Aline Bessa
none Details | Review

Description lasagna davide 2009-04-10 13:22:25 UTC
Please describe the problem:
Hi,
The completion feature of the ipython_view.py source file is not working as expected in some cases. I'm using the ipython_view.py console in an application i'm developing.

Steps to reproduce:
1. set two variables with a common prefix:  x1 = 1 and x2 = 2 
2. now write: type(x)
3. put the cursor between the x and the closing bracket
4. press tab



Actual results:
instead of having a list of variable starting with x, that is x1 and x2, lots of other variables are thrown out.

Expected results:
i would expect a list of the variables starting with x

Does this happen every time?
yes

Other information:
Comment 1 lasagna davide 2009-04-10 17:37:49 UTC
I'm currently writing a patch to fix this... hope to be able to fix it.. :)
Comment 2 lasagna davide 2009-04-10 21:07:53 UTC
i think that this bug derives from two causes and i've managed to fix the first one , but i can't figure out how to fix the second one.
1) in the complete() method of the IterableIPShell class the string to pass to the IP.complete method is not 
  split_line = self.complete_sep.split(line)
but we want to pass it  the string between the cursor and the first blank space at his left. This can be done  for example with this code:
split_line = self.complete_sep.split(line)
		# we pass to IP.complete the string to be completed. 
		# this is the string between the cursor and the first blank space at his left
		cursor_iter = self.text_buffer.get_iter_at_mark( self.text_buffer.get_insert() )
		end_iter = self.text_buffer.get_end_iter()
		#this is a "dirty hack"
		text_from_cursor_to_the_end = self.text_buffer.get_text(cursor_iter, end_iter)
		if text_from_cursor_to_the_end:
			string_to_complete = split_line[-1].split(text_from_cursor_to_the_end)[0]
		else:
			string_to_complete = split_line[-1]
		
		possibilities = self.IP.complete(string_to_complete)


In this way the variable string_to_complete is the "true" prefix we would like to find matches for.

Then the code goes into the onKeyPressExtend method of the ipythonview class and there is a call to showPrompt() and changeline.. but i cannot figure out  how to fix the bad behaviour we have. Sorry, i'm quite new to python 

Hope that someone fixes this..

Cheers
Comment 3 lasagna davide 2009-04-10 21:09:44 UTC
i think that this bug derives from two causes and i've managed to fix the first one , but i can't figure out how to fix the second one.
1) in the complete() method of the IterableIPShell class the string to pass to the IP.complete method is not 
  split_line = self.complete_sep.split(line)
but we want to pass it  the string between the cursor and the first blank space at his left. This can be done  for example with this code:

split_line = self.complete_sep.split(line)
# we pass to IP.complete the string to be completed. 
# this is the string between the cursor and the first blank space at his left
cursor_iter = self.text_buffer.get_iter_at_mark( self.text_buffer.get_insert() )
end_iter = self.text_buffer.get_end_iter()
#this is a "dirty hack"
text_from_cursor_to_the_end = self.text_buffer.get_text(cursor_iter, end_iter)
if text_from_cursor_to_the_end:
  string_to_complete = split_line[-1].split(text_from_cursor_to_the_end)[0]
else:
  string_to_complete = split_line[-1]
possibilities = self.IP.complete(string_to_complete)


In this way the variable string_to_complete is the "true" prefix we would like to find matches for.

Then the code goes into the onKeyPressExtend method of the ipythonview class and there is a call to showPrompt() and changeline.. but i cannot figure out  how to fix the bad behaviour we have. Sorry, i'm quite new to python 

Hope that someone fixes this..

Cheers
Comment 4 Eitan Isaacson 2009-04-11 13:03:19 UTC
Haven't looked at this code in a very long time. If you provide a fix, I would be happy to use it.
Comment 5 Aline Bessa 2011-06-22 20:30:44 UTC
Bug confirmed.
Comment 6 Aline Bessa 2011-07-04 22:55:23 UTC
Created attachment 191257 [details] [review]
lasagna davide's solution for completion feature

Bug #500900 was fixed and your code alone, lasagna davide, solves the whole problem. I tested it a lot in 3.1.2 and 3.1.3 accerciser's versions and it works! 

Since the patch I'm attaching is a simple copy of lasagna's work, a maintainer that wants to push it to accerciser's master should set the patch's authorship to him - not to me.
Comment 7 GNOME Infrastructure Team 2021-05-17 15:43:35 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/accerciser/-/issues/30.