[gedit-plugins/gnome-2-32] Fix completion for prompts
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins/gnome-2-32] Fix completion for prompts
- Date: Sun, 29 Aug 2010 22:55:29 +0000 (UTC)
commit 248ed73d343924ce230589494c7c831cf20fc9b8
Author: Jesse van den Kieboom <jesse icecrew nl>
Date: Sat Jun 19 15:15:09 2010 +0200
Fix completion for prompts
plugins/commander/commander/commands/__init__.py | 7 +++++--
plugins/commander/commander/entry.py | 16 ++++++++++++----
2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/plugins/commander/commander/commands/__init__.py b/plugins/commander/commander/commands/__init__.py
index a9d165d..b2d23f7 100644
--- a/plugins/commander/commander/commands/__init__.py
+++ b/plugins/commander/commander/commands/__init__.py
@@ -66,11 +66,14 @@ class Commands(Singleton):
self.retval = None
def autocomplete_func(self):
- if retval == result.Result.PROMPT:
- return retval.autocomplete
+ if self.retval == result.Result.PROMPT:
+ return self.retval.autocomplete
else:
return {}
+ def args(self):
+ return [], True
+
class State:
def __init__(self):
self.clear()
diff --git a/plugins/commander/commander/entry.py b/plugins/commander/commander/entry.py
index bc48ebd..26a9939 100644
--- a/plugins/commander/commander/entry.py
+++ b/plugins/commander/commander/entry.py
@@ -462,12 +462,17 @@ class Entry(gtk.EventBox):
ret = commands.completion.command(words=wordsstr, idx=posidx)
else:
complete = None
+ realidx = posidx
if not self._command_state:
# Get the command first
cmd = commands.completion.single_command(wordsstr, 0)
+ realidx -= 1
+
+ ww = wordsstr[1:]
else:
cmd = self._command_state.top()
+ ww = wordsstr
if cmd:
complete = cmd.autocomplete_func()
@@ -483,8 +488,8 @@ class Entry(gtk.EventBox):
s = ['argstr', 'args', 'entry', 'view']
args = filter(lambda x: not x in s, args)
- if posidx - 1 < len(args):
- arg = args[posidx - 1]
+ if realidx < len(args):
+ arg = args[realidx]
elif varargs:
arg = '*'
else:
@@ -498,9 +503,12 @@ class Entry(gtk.EventBox):
try:
spec = utils.getargspec(func)
+ if not ww:
+ ww = ['']
+
kwargs = {
- 'words': wordsstr[1:],
- 'idx': posidx - 1,
+ 'words': ww,
+ 'idx': realidx,
'view': self._view
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]