Skip to content

Commit d1c986d

Browse files
committed
Added: Keybinding: Pin/Unpin selected/active tabs (#370)
1 parent 7774fb3 commit d1c986d

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/_locales/dict.browser.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@
421421
"en": "Duplicate selected (or active) tabs",
422422
"ru": "Дублировать выбранные (или активные) вкладки"
423423
},
424+
"KbPinTabs": {
425+
"en": "Pin/Unpin selected (or active) tabs",
426+
"ru": "Закрепить/Открепить выбранные (или активные) вкладки"
427+
},
424428
"KbSearch": {
425429
"en": "Search",
426430
"ru": "Поиск",

src/manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@
326326
},
327327
"duplicate_tabs": {
328328
"description": "__MSG_KbDuplicateTabs__"
329+
},
330+
"pin_tabs": {
331+
"description": "__MSG_KbPinTabs__"
329332
}
330333
},
331334

src/page.setup/components/keybindings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { SetupPage } from 'src/services/setup-page'
2323
import KeybindingField from 'src/page.setup/components/keybindings.keybinding.vue'
2424
2525
const layout = [
26-
['general', '_execute_sidebar_action', 'search', 'create_snapshot', 'duplicate_tabs'],
26+
['general', '_execute_sidebar_action', 'search', 'create_snapshot', 'duplicate_tabs', 'pin_tabs'],
2727
2828
// Creating / Removing tab
2929
[

src/services/keybindings.actions.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ function onCmd(name: string): void {
174174
const globaly = Settings.state.scrollThroughTabs === 'global'
175175
Tabs.switchTab(globaly, Settings.state.scrollThroughTabsCyclic, -1, false)
176176
} else if (name === 'duplicate_tabs') onKeyDuplicateTabs(false)
177+
else if (name === 'pin_tabs') onKeyPinTabs()
177178
}
178179

179180
function onKeySwitchToTab(targetIndex?: number): void {
@@ -941,6 +942,17 @@ function onKeyDuplicateTabs(branch: boolean) {
941942
Tabs.duplicateTabs(ids)
942943
}
943944

945+
function onKeyPinTabs() {
946+
const ids = Selection.isTabs() ? Selection.get() : [Tabs.activeId]
947+
if (!ids.length) return
948+
949+
const firstTab = Tabs.byId[ids[0]]
950+
if (!firstTab) return
951+
952+
if (firstTab.pinned) Tabs.unpinTabs(ids)
953+
else Tabs.pinTabs(ids)
954+
}
955+
944956
/**
945957
* Setup keybinding listeners
946958
*/

0 commit comments

Comments
 (0)