Skip to content

Commit fdef31e

Browse files
committed
add keybindings for move file up/down
1 parent 1b19cea commit fdef31e

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

release/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,16 @@
10391039
"mac": "alt\u002Bshift\u002BEnter",
10401040
"when": "editorFocus \u0026\u0026 !findWidgetVisible \u0026\u0026 editorLangId == \u0027fsharp\u0027"
10411041
},
1042+
{
1043+
"command": "fsharp.explorer.moveUp",
1044+
"key": "alt\u002Bup",
1045+
"when": "focusedView == 'ionide.projectExplorerInActivity' \u007C\u007C focusedView == 'ionide.projectExplorer'"
1046+
},
1047+
{
1048+
"command": "fsharp.explorer.moveDown",
1049+
"key": "alt\u002Bdown",
1050+
"when": "focusedView == 'ionide.projectExplorerInActivity' \u007C\u007C focusedView == 'ionide.projectExplorer'"
1051+
},
10421052
{
10431053
"command": "fsharp.generateDoc",
10441054
"key": "alt\u002Bshift\u002Bj",

src/Components/SolutionExplorer.fs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,11 @@ module SolutionExplorer =
935935
None)
936936
|> context.Subscribe
937937

938+
let treeOptions = createEmpty<TreeViewOptions<Model>>
939+
treeOptions.treeDataProvider <- provider
940+
let treeView = window.createTreeView (treeViewId, treeOptions)
941+
context.subscriptions.Add(unbox (box treeView))
942+
938943
commands.registerCommand ("fsharp.NewProject", newProject |> objfy2)
939944
|> context.Subscribe
940945

@@ -957,25 +962,27 @@ module SolutionExplorer =
957962

958963
commands.registerCommand (
959964
"fsharp.explorer.moveUp",
960-
objfy2 (fun m ->
961-
match unbox m with
962-
| File(_, _, name, Some virtPath, proj) -> FsProjEdit.moveFileUpPath proj virtPath
963-
| _ -> undefined
964-
|> ignore
965-
966-
None)
965+
objfy2 (
966+
Option.ofObj
967+
>> Option.map unbox
968+
>> Option.orElseWith (fun () -> treeView.selection |> Seq.tryHead)
969+
>> Option.iter (function
970+
| File(_, _, _, Some virtPath, proj) -> FsProjEdit.moveFileUpPath proj virtPath |> ignore
971+
| _ -> ())
972+
)
967973
)
968974
|> context.Subscribe
969975

970976
commands.registerCommand (
971977
"fsharp.explorer.moveDown",
972-
objfy2 (fun m ->
973-
match unbox m with
974-
| File(_, _, name, Some virtPath, proj) -> FsProjEdit.moveFileDownPath proj virtPath
975-
| _ -> undefined
976-
|> ignore
977-
978-
None)
978+
objfy2 (
979+
Option.ofObj
980+
>> Option.map unbox
981+
>> Option.orElseWith (fun () -> treeView.selection |> Seq.tryHead)
982+
>> Option.iter (function
983+
| File(_, _, _, Some virtPath, proj) -> FsProjEdit.moveFileDownPath proj virtPath |> ignore
984+
| _ -> ())
985+
)
979986
)
980987
|> context.Subscribe
981988

@@ -1154,11 +1161,6 @@ module SolutionExplorer =
11541161
)
11551162
|> context.Subscribe
11561163

1157-
let treeOptions = createEmpty<TreeViewOptions<Model>>
1158-
treeOptions.treeDataProvider <- provider
1159-
let treeView = window.createTreeView (treeViewId, treeOptions)
1160-
context.subscriptions.Add(unbox (box treeView))
1161-
11621164
NodeReveal.activate context rootChanged.event treeView
11631165

11641166
let wsProvider =

0 commit comments

Comments
 (0)