-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: shortcut added for reopening last closed tab #1963
base: master
Are you sure you want to change the base?
feat: shortcut added for reopening last closed tab #1963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for contributing this! I think your logic is sound, but I've added a few pointers to help us do this in the right place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! This still needs one more change to account for the fact that the original tab was deleted from the database.
Hi @rathboma here is the video. Let me know if it's okay or I'm missing something here Screencast.from.2024-04-05.15-16-25.mp4 |
Hey, it will work, but when you close and re-open Beekeeper Studio those tabs will be missing, because they were deleted from the database. That's why the tabs need to go through the sequence I described. |
@azmy60 this doesn't require much to fix for merging, see the comments above. You should be able to commit directly to this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def still needs some work
async reopenLastClosedTab(context) { | ||
for (let i = context.state.lastClosedTabs.length - 1; i >= 0; i--) { | ||
const tab = context.state.lastClosedTabs[i] | ||
// Does this tab belong to the current connection? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you also have to check workspace id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenTab
here has still been removed from the database and doesn't have an ID, so it still needs saving.
Also -- what happens with the position of the tab? Does it go back to the right place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that we want this to behave like vscode, so no need to save lastClosedTabs
to database. But I just realized that chrome persists the closed tabs even though I exit the program. I'll take a look on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we even not remove tabs from database and just mark it as "closed"? like soft delete.
@@ -78,6 +86,18 @@ export const TabModule: Module<State, RootState> = { | |||
context.commit('set', []) | |||
context.commit('setActive', null) | |||
}, | |||
async reopenLastClosedTab(context) { | |||
for (let i = context.state.lastClosedTabs.length - 1; i >= 0; i--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we looping here? We only want the very last item in the lastClosedTabs array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid opening a tab that's from a different connection.
Using array.pop
would get the last item, but that item could be from a different connectionId
.
An example to this case is:
- close tabs in connection A
- disconnect from A and connect to B
- press ctrl+shift+T
- tabs that were in connection A are now in B
Another solution to this is I was thinking if we should just wipe out the stack so it's empty whenever we connect to a new connection, but maybe it's better to do the first one since we can?
EDIT: This implementation will probably change to using array.pop
if I save the closed tabs to database.
It's hard to restore closed tabs in the right position, when all positions of tabs were always `99`.
addressing: #1768
added Ctrl+Shift+T shortcut to re-open recently closed tab