Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • thg thg
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 829
    • Issues 829
    • List
    • Boards
    • Service Desk
    • Milestones
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • mercurial
  • TortoiseHg
  • thgthg
  • Issues
  • #5368
Closed
Open
Created Mar 25, 2019 by Bitbucket Importer@bitbucket_importerOwner

Implement default keyboard shortcuts for switching repository Tabs (esp. Ctrl+(Shift)+Tab)

Created originally on Bitbucket by thomasdd (Thomas D.)

In the entire tabbed IT universe, Ctrl+Tab / Ctrl+Shift+Tab can be used to switch between the last activated tabs. Browers like Firefox, MDI-Editors like Notepad++, Windows itself with Alt+Tab / Alt+Shift+Tab, you name it: It just works EVERYWHERE. But sadly, NOT in THG...

I have never discovered Ctrl+1, Ctrl+2 etc. for Tab switching in THG until I found #3543 (closed) today. Unfortunately, having those keyboard shortcuts on file menu does not make them discoverable enough. Worse, they are not very practical. Anyone having more than 9 repositories can't use them to switch between any tabs beyond tab 9. And depending on workflows, arrangement of tabs may change in between, which spoils the muscle memory. Before I figure out if that tab is tab 7 or tab 8 so that I can press Ctrl+7 or 8 respectively, it's faster to just click on it anyway. But for just switching between 7 and 8 which I happen to use today, and 9 and 10 tomorrow, just using Ctrl+Tab is perfectly memorable as a no-brainer, every time.

In #3543 (closed), @yuja objected:

But "ordered by last activation" will increase the complexity of the big Workbench class. It'll be necessary to factor out tab-related functions first.

I think that's not true. "Ordered by last activation" is quite simple, just keep a single array with tab indices, ordered by tab activation, last activated first. Here's a rough sketch how (pseudo code leaning on javascript syntax; I don't know Python):

let globalTabSwitchSeqArray = [];

function onTabFocusEventHandler() {
  let currentTabIndex = tabsObject.getCurrentTabIndex(); // Index: 1st tab = 0 etc.
  if (!globalTabSwitchSeqArray[currentTabIndex]) {
    // add new tab id to start of tab switch array
    globalTabSwitchSeqArray.unshift(currentTabIndex); // when opening e.g. 3rd tab: [2, 1, 0]
  } else {
    // existing tab focused, e.g. Tab 2, move it to begin of tab-switch-array
    array_move(globalTabSwitchSeqArray, globalTabSwitchSeqArray.indexOf(currentTabIndex), 0);
    // new tab switch order: [1,2,0]
  }
}

function workbenchOnKeyPress (event) {
  if (event.key == "Tab" && event.CtrlKey) {
    if (event.ShiftKey) {
      // backwards in activation sequence: activate last tab in the sequence
     targetIndex = globalTabSwitchSeqArray.length-1;
      switchToTab(globalTabSwitchSeqArray[targetIndex]);
     } else {
      // forward in activation sequence: activate 2nd tab in the sequence
       switchToTab(globalTabSwitchSeqArray[1]);
     }
  }
}

function array_move(arr, old_index, new_index) {
    if (new_index >= arr.length) {
        var k = new_index - arr.length + 1;
        while (k--) {
            arr.push(undefined);
        }
    }
    arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
    return arr; // for testing
};

I haven't tested this in any way, but hopefully it's enough to get the idea.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking