Skip to content

Commit

Permalink
fix: allow create file in empty dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven committed Oct 8, 2024
1 parent 831bf5d commit 8d51b78
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oil-terminal",
"version": "0.0.3",
"version": "0.0.5",
"license": "MIT",
"author": "mysteryven",
"description": "Manage and navigate file system easily from your terminal.",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ const App = (props: Props) => {
const [list, setList] = useFileList(currentDir, [reloadFlag])
const [mode, setMode] = useState<Mode>('Normal')

let initialIndex = Math.min(list.length, 1)
let initialIndex = list.length === 1 ? 0 : 1
// we are back to a parent dir
if (lastDir) {
initialIndex = list.findIndex((fileMeta) => fileMeta.filename === lastDir)
}
const [activeIndex, setActiveIndex] = useActiveIndex(initialIndex, list.length, mode, [currentDir, initialIndex])
const [_debug, setDebug] = useState<any>()
const offset = useOffset(activeIndex, list.length)

useEffect(() => {
setDebug(`reloadFlag${reloadFlag}, currentDir: ${currentDir}, activeIndex: ${activeIndex}, mode: ${mode}`)
}, [reloadFlag, currentDir, activeIndex, mode])

// switch mode
useInput((_input, key) => {
if (key.escape) {
Expand Down

0 comments on commit 8d51b78

Please sign in to comment.