Skip to content
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

Prefill the file dialog with the old name when renaming a file #1934

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Components/SolutionExplorer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,15 @@ module SolutionExplorer =
else
(fn + ".fs")

let private createNewFileDialg (proj: string) (existingFiles: list<Model>) (prompt: string) =
let private createNewFileDialg
(proj: string)
(existingFiles: list<Model>)
(prompt: string)
(prefilled: string Option)
=
let opts = createEmpty<InputBoxOptions>
opts.placeHolder <- Some "new.fs"
opts.value <- prefilled
opts.prompt <- Some prompt

opts.validateInput <-
Expand Down Expand Up @@ -875,7 +881,11 @@ module SolutionExplorer =
| Some model ->
match tryFindParentProject model with
| Some(Project(_, proj, _, files, _, _, _, _)) ->
createNewFileDialg proj files "Enter a new name"
createNewFileDialg
proj
files
"Enter a new name"
(Some(virtualPath.Split([| '/' |]) |> Array.last))
|> Promise.ofThenable
|> Promise.bind (fun newFileNameOpt ->
promise {
Expand Down Expand Up @@ -909,7 +919,7 @@ module SolutionExplorer =
| Some model ->
match tryFindParentProject model with
| Some(Project(_, proj, _, files, _, _, _, _)) ->
createNewFileDialg proj files "New file name, relative to selected file"
createNewFileDialg proj files "New file name, relative to selected file" None
|> Promise.ofThenable
|> Promise.bind (fun file ->
match file with
Expand All @@ -933,7 +943,7 @@ module SolutionExplorer =
| Some model ->
match tryFindParentProject model with
| Some(Project(_, proj, _, files, _, _, _, _)) ->
createNewFileDialg proj files "New file name, relative to selected file"
createNewFileDialg proj files "New file name, relative to selected file" None
|> Promise.ofThenable
|> Promise.map (fun file ->
match file with
Expand All @@ -954,7 +964,7 @@ module SolutionExplorer =
objfy2 (fun m ->
match unbox m with
| Project(_, proj, _, files, _, _, _, _) ->
createNewFileDialg proj files "New file name, relative to project file"
createNewFileDialg proj files "New file name, relative to project file" None
|> Promise.ofThenable
|> Promise.map (fun file ->
match file with
Expand Down