Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure correct sidebar item is focused, or none, when tab removed #1320

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,14 @@ namespace Scratch {
update_find_actions ();
});

document_view.tab_removed.connect (() => {
document_view.tab_removed.connect ((tab) => {
update_find_actions ();
var doc = (Scratch.Services.Document)tab;
var selected_item = (Scratch.FolderManager.Item?)(folder_manager_view.selected);
if (selected_item != null && selected_item.file.file.equal (doc.file)) {
// Do not leave removed tab selected
folder_manager_view.selected = null;
}
});

document_view.document_change.connect ((doc) => {
Expand Down
6 changes: 4 additions & 2 deletions src/Widgets/DocumentView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ public class Scratch.Widgets.DocumentView : Granite.Widgets.DynamicNotebook {
});

tab_switched.connect ((old_tab, new_tab) => {
/* The 'document_change' signal is emitted when the document is focused. We do not need to emit it here */
save_focused_document_uri (new_tab as Services.Document);
var doc = (Services.Document)new_tab;
/* The 'document_change' signal may not be emitted if this already has focus so signal here*/
document_change (doc, this);
save_focused_document_uri (doc);
});

tab_restored.connect ((label, restore_data, icon) => {
Expand Down