Fix None prompt until manually changed

The GeminiClient's constructor expected set_prompt to return the prompt,
while the function directly mutated it without returning anything.

This manifested as having "None" as prompt instead of the default "ON>", until
entering the offline command.

This patch both fixes the constructor by not setting self.prompt to the
result of GeminiClient.set_prompt, *and* make that function return the
prompt as well. Each of those is a separated hunk, feel free to only
apply whichever feels best (though applying both should warrant any
future mistake of the sort).

Signed-off-by: Austreelis <dev@austreelis.net>
This commit is contained in:
Austreelis 2023-09-23 02:08:48 +02:00 committed by Lionel Dricot
parent f8d185eac9
commit 39c5f17a39
1 changed files with 2 additions and 1 deletions

View File

@ -142,7 +142,7 @@ class GeminiClient(cmd.Cmd):
os.umask(0o077)
self.opencache = opnk.opencache()
self.theme = offthemes.default
self.prompt = self.set_prompt("ON")
self.set_prompt("ON")
self.current_url = None
self.hist_index = 0
self.marks = {}
@ -222,6 +222,7 @@ class GeminiClient(cmd.Cmd):
self.prompt = "\001\x1b[%sm\002"%open_color + prompt + "\001\x1b[%sm\002"%close_color + "> "
#support for 256 color mode:
#self.prompt = "\001\x1b[38;5;76m\002" + "ON" + "\001\x1b[38;5;255m\002" + "> " + "\001\x1b[0m\002"
return self.prompt
def complete_list(self,text,line,begidx,endidx):
allowed = []