Skip to content

Commit

Permalink
Fixed open file picker
Browse files Browse the repository at this point in the history
  • Loading branch information
notangelmario authored Nov 8, 2023
1 parent 7b56700 commit ee1d9b5
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions src/lib/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ export async function showOpenFilePicker() {
const selected = await openFile({
multiple: false,
directory: false,
filters: [{
name: "Markdown",
extensions: ["md"]
}]
filters: pickerFilters
})

return selected as string
Expand Down Expand Up @@ -68,52 +65,7 @@ export async function setEditorText(editor: monaco.editor.IStandaloneCodeEditor,
export async function showSaveFilePicker() {
try {
const selected = await saveFile({
filters: [
{
name: "Markdown",
extensions: ["md"]
},
{
name: "Text",
extensions: ["txt"]
},
{
name: "Shell Script",
extensions: ["sh"]
},
{
name: "C",
extensions: ["c"]
},
{
name: "C++",
extensions: ["cpp"]
},
{
name: "Python",
extensions: ["py"]
},
{
name: "CSS",
extensions: ["css"]
},
{
name: "HTML",
extensions: ["html"]
},
{
name: "JSON",
extensions: ["json"]
},
{
name: "JavaScript",
extensions: ["js"]
},
{
name: "TypeScript",
extensions: ["ts"]
}
]
filters: pickerFilters
})

return selected as string
Expand Down Expand Up @@ -169,6 +121,53 @@ export function getExtension(fname: string) {
return fname.slice((Math.max(0, fname.lastIndexOf(".")) || Infinity) + 1);
}

export const pickerFilters = [
{
name: "Markdown",
extensions: ["md"]
},
{
name: "Text",
extensions: ["txt"]
},
{
name: "Shell Script",
extensions: ["sh"]
},
{
name: "C",
extensions: ["c"]
},
{
name: "C++",
extensions: ["cpp"]
},
{
name: "Python",
extensions: ["py"]
},
{
name: "CSS",
extensions: ["css"]
},
{
name: "HTML",
extensions: ["html"]
},
{
name: "JSON",
extensions: ["json"]
},
{
name: "JavaScript",
extensions: ["js"]
},
{
name: "TypeScript",
extensions: ["ts"]
}
]

export const fileTypes = new Map<string, string>([
["txt", "plaintext"],
["sh", "shell"],
Expand Down

0 comments on commit ee1d9b5

Please sign in to comment.