Skip to content

Commit

Permalink
fix bug: Save content saves only visible screen
Browse files Browse the repository at this point in the history
fix this bug: Guake#1958
copy the fix from this PR: Guake#2218
  • Loading branch information
PhungXuanAnh committed Nov 26, 2024
1 parent 7e3b6ce commit 285bccd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions guake/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,24 @@ def __init__(self, terminal, window):
self.parent_window = window

def run(self):
self.terminal.select_all()
self.terminal.copy_clipboard()
self.terminal.unselect_all()
clipboard = Gtk.Clipboard.get_default(self.parent_window.get_display())
selection = clipboard.wait_for_text()
if not selection:
return
selection = selection.rstrip()
# row from get_cursor_position takes the scrollback rows into account automatically
row = self.terminal.get_cursor_position()[1]
# Get the max col, not where the cursor is, to avoid losing text at the end
col = self.terminal.get_column_count()
content = self.terminal.get_text_range(0, 0, row, col)

if content and content[0]:
selection = content[0].rstrip().lstrip()
else: # Call the original method if get_text_range fails for some reason. (Can it fail?)
self.terminal.select_all()
self.terminal.copy_clipboard()
self.terminal.unselect_all()
clipboard = Gtk.Clipboard.get_default(self.parent_window.get_display())
selection = clipboard.wait_for_text()
if not selection:
return
selection = selection.rstrip()

filter = Gtk.FileFilter()
filter.set_name(_("All files"))
filter.add_pattern("*")
Expand Down

0 comments on commit 285bccd

Please sign in to comment.