Skip to content

Commit

Permalink
[M] Collapse pin state switch actions
Browse files Browse the repository at this point in the history
- Move pin switch button 📌 from view navigation
	 to secondary actions to reduce the count of buttons
- Add toggle prefix ✓ to pin switch buttons
- Refactor extension.ts
  • Loading branch information
Gerrnperl committed Mar 24, 2024
1 parent ddf28b8 commit 65fc35e
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 137 deletions.
74 changes: 68 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@
"icon": "$(pin)",
"category": "outline-map"
},
{
"command": "outline-map.unfreeze",
"title": "%om.cmd.unfreeze.title%",
"icon": "$(pinned)",
"category": "outline-map"
},
{
"command": "outline-map.freeze",
"title": "%om.cmd.freeze.title%",
Expand Down Expand Up @@ -525,21 +531,77 @@
}
],
"menus": {
"commandPalette": [
{
"command": "outline-map.unpin",
"when": "false"
},
{
"command": "outline-map.pin",
"when": "false"
},
{
"command": "outline-map.unfreeze",
"when": "false"
},
{
"command": "outline-map.freeze",
"when": "false"
},
{
"command": "outline-map.addDepth",
"when": "false"
},
{
"command": "outline-map.reduceDepth",
"when": "false"
},
{
"command": "outline-map.workspace.closeFile",
"when": "false"
},
{
"command": "outline-map.workspace.deleteSymbol",
"when": "false"
},
{
"command": "outline-map.workspace.excludeInFolder",
"when": "false"
},
{
"command": "outline-map.workspace.excludeInWorkspace",
"when": "false"
},
{
"command": "outline-map.workspace.excludeGlobally",
"when": "false"
},
{
"command": "outline-map.workspace.goToLocation",
"when": "false"
}
],
"view/title": [
{
"command": "outline-map.pin",
"when": "view == outline-map-view && outline-map.pin-status == 0",
"group": "navigation"
"when": "view == outline-map-view && outline-map.pin-status != 1",
"group": "pin@1"
},
{
"command": "outline-map.unpin",
"when": "view == outline-map-view && outline-map.pin-status == 2",
"group": "navigation"
"when": "view == outline-map-view && outline-map.pin-status == 1",
"group": "pin@2"
},
{
"command": "outline-map.freeze",
"when": "view == outline-map-view && outline-map.pin-status == 1",
"group": "navigation"
"when": "view == outline-map-view && outline-map.pin-status != 2",
"group": "pin@3"
},
{
"command": "outline-map.unfreeze",
"when": "view == outline-map-view && outline-map.pin-status == 2",
"group": "pin@4"
},
},
{
"command": "outline-map.addDepth",
Expand Down
7 changes: 4 additions & 3 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
"om.config.workspace.closeFileTimeout.description": "Specify the time to close the file when not clicked (in seconds). Set to 0 to disable timeout closing.",
"om.cmd.reduceDepth.title": "Reduce Depth",
"om.cmd.addDepth.title": "Increase Depth",
"om.cmd.unpin.title": "Unpin",
"om.cmd.pin.title": "Pin",
"om.cmd.freeze.title": "Freeze",
"om.cmd.unpin.title": "✓ Pin",
"om.cmd.unfreeze.title": "✓ Freeze",
"om.cmd.pin.title": "​  Pin",
"om.cmd.freeze.title": "​  Freeze",
"om.cmd.toggleSearch.title": "Toggle Search",
"om.cmd.focusSearch.title": "Focus Search",
"om.cmd.workspace.closeFile.title": "Close File",
Expand Down
7 changes: 4 additions & 3 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
"om.config.workspace.closeFileTimeout.description": "指定未单击时关闭文件的时间(以秒为单位)。设置为0以禁用超时关闭。",
"om.cmd.reduceDepth.title": "减少大纲深度",
"om.cmd.addDepth.title": "增加大纲深度",
"om.cmd.unpin.title": "大纲: 取消固定",
"om.cmd.pin.title": "大纲: 固定",
"om.cmd.freeze.title": "大纲: 冻结",
"om.cmd.unpin.title": "✓ 固定",
"om.cmd.unfreeze.title": "✓ 冻结",
"om.cmd.pin.title": "​  固定",
"om.cmd.freeze.title": "​  冻结",
"om.cmd.toggleSearch.title": "切换搜索",
"om.cmd.focusSearch.title": "聚焦搜索",
"om.cmd.workspace.closeFile.title": "关闭文件",
Expand Down
19 changes: 12 additions & 7 deletions src/extension/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { config } from './config';
import { ChangeDepthMsg, FocusMsg, PinSMsg, PinStatus } from '../common';
import { SymbolTreeItem, WorkspaceSymbols } from './workspace';


export interface Command {
name: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fn: (...args: any[]) => any;
}


function changeDepth(outlineProvider: OutlineView, deltaDepth = 1) {
outlineProvider.postMessage({
type: 'changeDepth',
Expand Down Expand Up @@ -71,13 +79,6 @@ if (config.defaultMaxDepth() > 0) {
// Set initial pin status as unpinned
commands.executeCommand('setContext', 'outline-map.pin-status', PinStatus.unpinned);


export interface Command {
name: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fn: (...args: any[]) => any;
}

export const OutlineViewCommandList: Command[] = [
{
name: 'outline-map.reduceDepth',
Expand All @@ -99,6 +100,10 @@ export const OutlineViewCommandList: Command[] = [
name: 'outline-map.freeze',
fn: freeze,
},
{
name: 'outline-map.unfreeze',
fn: unpin,
},
{
name: 'outline-map.toggleSearch',
fn: switchSearchField,
Expand Down
Loading

0 comments on commit 65fc35e

Please sign in to comment.