From 238ca8c812e000db5b251c1a90f924665c6de8d3 Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Mon, 24 Nov 2025 22:43:12 +0100 Subject: [PATCH] Add chokidar to repo --- README.md | 8 ++++++- package-lock.json | 48 ++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ src/main/fileOperations.ts | 10 ++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1b5b77..3596e1f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ # Miller code editor This is a code editor/IDE based on CodeMirror. -Its primary goal is to provide the user with a stack/column-based navigation history, making codebase navigation easier without getting lost. \ No newline at end of file +Its primary goal is to provide the user with a stack/column-based navigation history, making codebase navigation easier without getting lost. + +## Features +- [*] Basic file editing +- [*] Terminal integration +- [ ] File watching +- [ ] LSP support \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6cab135..cb7f0b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.1.0", "license": "MIT", "dependencies": { + "chokidar": "^4.0.3", "electron-squirrel-startup": "^1.0.1", "node-pty": "^1.0.0" }, @@ -28,6 +29,7 @@ "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.39.1", "@tailwindcss/vite": "^4.1.17", + "@types/chokidar": "^1.7.5", "@types/electron-squirrel-startup": "^1.0.2", "@typescript-eslint/eslint-plugin": "^8.46.3", "@typescript-eslint/parser": "^8.46.3", @@ -3342,6 +3344,17 @@ "@types/responselike": "^1.0.0" } }, + "node_modules/@types/chokidar": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@types/chokidar/-/chokidar-1.7.5.tgz", + "integrity": "sha512-PDkSRY7KltW3M60hSBlerxI8SFPXsO3AL/aRVsO4Kh9IHRW74Ih75gUuTd/aE4LSSFqypb10UIX3QzOJwBQMGQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/events": "*", + "@types/node": "*" + } + }, "node_modules/@types/electron-squirrel-startup": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@types/electron-squirrel-startup/-/electron-squirrel-startup-1.0.2.tgz", @@ -3378,6 +3391,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/fs-extra": { "version": "9.0.13", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", @@ -4684,6 +4704,21 @@ "dev": true, "license": "MIT" }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -9879,6 +9914,19 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/rechoir": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", diff --git a/package.json b/package.json index fa4101d..a21f859 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.39.1", "@tailwindcss/vite": "^4.1.17", + "@types/chokidar": "^1.7.5", "@types/electron-squirrel-startup": "^1.0.2", "@typescript-eslint/eslint-plugin": "^8.46.3", "@typescript-eslint/parser": "^8.46.3", @@ -53,6 +54,7 @@ "vite": "^7.2.2" }, "dependencies": { + "chokidar": "^4.0.3", "electron-squirrel-startup": "^1.0.1", "node-pty": "^1.0.0" } diff --git a/src/main/fileOperations.ts b/src/main/fileOperations.ts index e48cf12..3a40759 100644 --- a/src/main/fileOperations.ts +++ b/src/main/fileOperations.ts @@ -6,6 +6,8 @@ import fs from "fs"; const fsp = fs.promises; import path from "path"; +import * as chokidar from "chokidar"; + type FolderTree = { name: string; path: string; @@ -15,6 +17,7 @@ type FolderTree = { // Track the currently opened folder for security checks let currentWorkspaceRoot: string | null = null; +let watcher: chokidar.FSWatcher | null = null; // Track previously opened files outside the workspace const openedFiles = new Set(); @@ -55,6 +58,13 @@ export async function handleOpenFolder( if (!result.canceled && result.filePaths.length > 0) { const folderPath = result.filePaths[0]; currentWorkspaceRoot = folderPath; // Track the opened folder + watcher = chokidar.watch(folderPath, { + ignoreInitial: true, + }); + watcher.on("all", (event, path) => { + console.log("chokidar", event, path); + }); + return { name: path.basename(folderPath), path: folderPath,