Reopen accidentally closed tab
AbandonedPublic

Authored by kossebau on Mar 26 2017, 2:52 PM.

Details

Reviewers
mwolff
apol
coopht
Group Reviewers
KDevelop
Summary

Add functionality to open accidentally closed tab from container's menu or using hotkey (Meta + T).

Test Plan

Check that it is possible to reopen closed tab from menu from different views
Check that it is possible to reopen closed tab using hoitkey from different views

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
coopht created this revision.Mar 26 2017, 2:52 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptMar 26 2017, 2:52 PM
brauch added a subscriber: brauch.Mar 26 2017, 7:13 PM

Looks good except what is noted below, thanks!

sublime/container.cpp
309

why do you need the cast here?

365

there is no point in using qobject_cast over static_cast if you don't check the result; not sure if you need to?

sublime/mainwindow_p.cpp
136

I suggest Ctrl+Shift+T, like in Firefox for example. I think meta is weird for shortcuts, it is not used anywhere else.

coopht marked an inline comment as done.Mar 26 2017, 7:34 PM
coopht added inline comments.
sublime/container.cpp
365

I will result check here.

sublime/mainwindow_p.cpp
136

I use Meta+T because Ctrl+Shit+T is already in use by Split View Top/Bottom action.
Should I change default shortcut for Split View Top/Bottom action ?

coopht updated this revision to Diff 12851.Mar 26 2017, 9:07 PM

Update.
Take into account 'Close other tabs' action.

mwolff requested changes to this revision.Mar 26 2017, 9:58 PM
mwolff added a subscriber: mwolff.

I like the change in general, only wonder whether we need to introduce a new queue for that - can't we reuse the recent file mechanism instead? or do people really want to have an infinite history here?

browsers btw have this feature too, but they probably rely on their history feature for this purpose, right?

shell/mainwindow.cpp
519 ↗(On Diff #12851)

dito

shell/mainwindow.h
97 ↗(On Diff #12851)

remove space before &

shell/mainwindow_actions.cpp
192 ↗(On Diff #12851)

dito

shell/mainwindow_p.h
88 ↗(On Diff #12851)

dito

sublime/container.cpp
124 ↗(On Diff #12851)

dito

361 ↗(On Diff #12851)

remove space before (

367 ↗(On Diff #12851)

this could potentially end up storing tons of items... I wonder - could we instead rely on the "recent files" mechanism and only support reopening the last N items through that?

sublime/container.h
22 ↗(On Diff #12851)

forward-declare instead of include

88 ↗(On Diff #12851)

dito

sublime/mainwindow.cpp
416 ↗(On Diff #12851)

dito

sublime/mainwindow.h
144 ↗(On Diff #12851)

remove space before &

This revision now requires changes to proceed.Mar 26 2017, 9:58 PM
coopht marked 7 inline comments as done.Mar 26 2017, 10:43 PM
coopht added inline comments.
sublime/container.cpp
367 ↗(On Diff #12851)

I did not find proper way to use "recent files", because this list is application wide and we need to track separate queue of closed files for each container.
And also files are added to the "recent files" list on file open event, which is not very usable in our case.
I can limit the queue of closed files by 100 items. Is it enough?

coopht updated this revision to Diff 12853.Mar 26 2017, 10:48 PM
coopht edited edge metadata.

Fix style.

Would be a useful additions, I know I would have used it before :)

shell/mainwindow.cpp
519

Default argument values should be only in the declaration, no? At least my current and past compilers refuse to take such code, referring to -fpermissive. Hm, or only if both method declaration and definition have a default argument set?

What is the purpose of a default argument value only in the definition? Especially when installed headers will miss that info bit about the default argument value?
I have never seen this before.

@coopht: Your points re recent files are very valid - let's not use it.

But one point makes me wonder: You said

I did not find proper way to use "recent files", because this list is application wide and we need to track separate queue of closed files for each container.

The hotkey is also application wide, no? So how is this supposed to work in a split view configuration? I assumed it would simply restore the file in the corresponding container?

@mwolff

The hotkey is also application wide, no? So how is this supposed to work in a split view configuration? I assumed it would simply restore the file in the corresponding container?

Yes, It will restore files in corresponding container from container's queue.

Is it OK to limit queue by 100 entries ?

@kossebau

What is the purpose of a default argument value only in the definition? Especially when installed headers will miss that info bit about the default argument value?

I have never seen this before.

It's a mistake. I fixed it.
But the code was accepted by gcc-4.6.3

coopht updated this revision to Diff 12939.Mar 28 2017, 8:46 PM

Use stack to track closed files.
Use proper events to handle file closing.

apol added a subscriber: apol.Mar 29 2017, 1:34 AM

Wouldn't it make sense to implement it somewhere separate as an observer rather than making the current sublime/container class even bigger?

In D5183#98623, @apol wrote:

Wouldn't it make sense to implement it somewhere separate as an observer rather than making the current sublime/container class even bigger?

I don't think that these changes making sublime/container much bigger. This is a pretty small changes and the idea is to track closed files for each container.
What is the proper place to implement it as an observer?

apol added a comment.Mar 29 2017, 12:30 PM
In D5183#98625, @coopht wrote:
In D5183#98623, @apol wrote:

Wouldn't it make sense to implement it somewhere separate as an observer rather than making the current sublime/container class even bigger?

I don't think that these changes making sublime/container much bigger. This is a pretty small changes and the idea is to track closed files for each container.
What is the proper place to implement it as an observer?

You could add a ReopenAction class. Either in Sublime or the shell.

coopht updated this revision to Diff 13173.Apr 7 2017, 5:32 AM

Move reopenClosedTab functionality to ReopenAction class.

coopht added a comment.EditedApr 7 2017, 5:41 AM
In D5183#98731, @apol wrote:
In D5183#98625, @coopht wrote:
In D5183#98623, @apol wrote:

Wouldn't it make sense to implement it somewhere separate as an observer rather than making the current sublime/container class even bigger?

I don't think that these changes making sublime/container much bigger. This is a pretty small changes and the idea is to track closed files for each container.
What is the proper place to implement it as an observer?

You could add a ReopenAction class. Either in Sublime or the shell.

I moved it to ReopenAction.
If ReopenAction is used in shell/MainWindow or sublime/MainWindow than it become more complicated to maintain separate lists of recently closed files for each view.
I suggest to use ReopenAction in the container, to simplify support of separate views for each view.
I tried to minimize my changes to the container class.

apol requested changes to this revision.Apr 7 2017, 11:55 PM
apol added inline comments.
sublime/reopenaction.cpp
34 ↗(On Diff #13173)

Why is it called action? It makes it look like it inherits QAction.

Or actually, make it inherit it! note it's only instantiated once and then coupled with the action.

49 ↗(On Diff #13173)

Why don't we just call ICore::self()->documentController()->openDocument(doc) here? We'll avoid all this tampering with the shell and sublime.

It's what this all ends up doing anyway.

63 ↗(On Diff #13173)

We should probably include more information than the url here, like the cursor position and even viewport.

This revision now requires changes to proceed.Apr 7 2017, 11:55 PM

Hi Alexander,

When I accidentally close a file, I use the existing action "Previous Visited Context". What you are implementing is only useful after accidentally closing several files. Is that what you want?

Hi Alexander,

When I accidentally close a file, I use the existing action "Previous Visited Context". What you are implementing is only useful after accidentally closing several files. Is that what you want?

Hi Alexander.
Yes, that what I want.
Also, if you close tab, which was not visited, you are unable to reopen it with "Previous Visited Context".

kfunk added a subscriber: kfunk.Jun 5 2017, 12:19 PM

@coopht Planning to address apol's concerns?

coopht added a comment.Jun 5 2017, 1:22 PM
In D5183#114278, @kfunk wrote:

@coopht Planning to address apol's concerns?

Yes, hope I will do it soon. I'm a bit busy at work now :-(

In D5183#114278, @kfunk wrote:

@coopht Planning to address apol's concerns?

Yes, hope I will do it soon. I'm a bit busy at work now :-(

Hi @coopht , still busy at work? :)

There has been no more activity on this WIP patch since more than a year. To keep our list of patches to review clean from dead ones, I would mark this review request as abandoned on Oct. 15th, unless there is an update. After that once there is some new version of the patch, it can be reactivated again.

Still looking forward to seeing you continue this patch :)

kossebau commandeered this revision.Oct 28 2018, 12:48 PM
kossebau abandoned this revision.
kossebau added a reviewer: coopht.

Abandoning for now given inactivity by the original author, for cleaning the to-reivew list. Still hoping one day someone/you will pick up this again.