-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change statusbar to be only for FileTabs * simplify statusbar plugin a lot * add reload warning * get rid of old status property * only show warning when file was modified
- Loading branch information
Showing
4 changed files
with
68 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
from porcupine import tabs | ||
from porcupine.plugins.statusbar import StatusBar | ||
|
||
|
||
# it must work with all kinds of tabs, not just FileTabs | ||
class AsdTab(tabs.Tab): | ||
pass | ||
def test_reload_warning(filetab, tmp_path): | ||
[statusbar] = [w for w in filetab.bottom_frame.winfo_children() if isinstance(w, StatusBar)] | ||
|
||
filetab.path = tmp_path / "lol.py" | ||
filetab.save() | ||
|
||
def test_that_it_doesnt_crash_with_different_numbers_of_tab_separated_parts(tabmanager): | ||
asd = AsdTab(tabmanager) | ||
tabmanager.add_tab(asd) | ||
filetab.path.write_text("hello") | ||
filetab.reload() | ||
filetab.update() | ||
assert statusbar.left_label['text'].endswith('lol.py') | ||
assert statusbar.left_label['foreground'] == '' | ||
|
||
events = [] | ||
asd.bind('<<StatusChanged>>', events.append, add=True) | ||
filetab.textwidget.insert('1.0', 'asdf') | ||
filetab.path.write_text("foo") | ||
filetab.reload() | ||
filetab.update() | ||
assert 'Press Ctrl+Z to get your changes back' in statusbar.left_label['text'] | ||
assert statusbar.left_label['foreground'] != '' | ||
|
||
asd.status = "a" | ||
asd.update() | ||
events.pop() | ||
|
||
asd.status = "a\tb\tc" | ||
asd.update() | ||
events.pop() | ||
|
||
asd.status = "a" | ||
asd.update() | ||
events.pop() | ||
|
||
tabmanager.close_tab(asd) | ||
assert not events | ||
filetab.textwidget.insert('1.0', 'a') # assume user doesn't want changes back | ||
assert statusbar.left_label['text'].endswith('lol.py') | ||
assert statusbar.left_label['foreground'] == '' |