diffwatch 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +125 -12
- package/dist/index.js.map +1 -1
- package/dist/utils/git.d.ts +1 -0
- package/dist/utils/git.js +30 -8
- package/dist/utils/git.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +480 -357
- package/src/utils/git.ts +28 -9
package/dist/index.js
CHANGED
|
@@ -23,14 +23,14 @@ function main() {
|
|
|
23
23
|
const args = process.argv.slice(2);
|
|
24
24
|
let repoPath = process.cwd();
|
|
25
25
|
const showHelp = () => {
|
|
26
|
-
console.log(`
|
|
27
|
-
Usage: diffwatch [path] [options]
|
|
28
|
-
|
|
29
|
-
Arguments:
|
|
30
|
-
path Path to the git repository (default: current directory)
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
-h, --help Show help information
|
|
26
|
+
console.log(`
|
|
27
|
+
Usage: diffwatch [path] [options]
|
|
28
|
+
|
|
29
|
+
Arguments:
|
|
30
|
+
path Path to the git repository (default: current directory)
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
-h, --help Show help information
|
|
34
34
|
`);
|
|
35
35
|
process.exit(0);
|
|
36
36
|
};
|
|
@@ -61,16 +61,23 @@ Options:
|
|
|
61
61
|
console.log(chalk_1.default.red(`Error: ${repoPath} is not a git repository.`));
|
|
62
62
|
process.exit(1);
|
|
63
63
|
}
|
|
64
|
+
// Force xterm-256color to encourage better mouse support on Windows terminals
|
|
65
|
+
if (process.platform === 'win32' && !process.env.TERM) {
|
|
66
|
+
process.env.TERM = 'xterm-256color';
|
|
67
|
+
}
|
|
64
68
|
const screen = blessed.screen({
|
|
65
69
|
smartCSR: true,
|
|
66
70
|
title: 'diffwatch',
|
|
71
|
+
mouse: true,
|
|
67
72
|
});
|
|
73
|
+
// Explicitly enable mouse tracking
|
|
74
|
+
screen.program.enableMouse();
|
|
68
75
|
const fileList = blessed.list({
|
|
69
76
|
top: 0,
|
|
70
77
|
left: 0,
|
|
71
78
|
width: '30%',
|
|
72
|
-
height: '
|
|
73
|
-
label: '
|
|
79
|
+
height: '99%',
|
|
80
|
+
label: 'Files (0)',
|
|
74
81
|
keys: true,
|
|
75
82
|
vi: true,
|
|
76
83
|
mouse: true,
|
|
@@ -90,7 +97,7 @@ Options:
|
|
|
90
97
|
top: 0,
|
|
91
98
|
left: '30%',
|
|
92
99
|
width: '70%',
|
|
93
|
-
height: '
|
|
100
|
+
height: '99%',
|
|
94
101
|
label: ' Diff () ',
|
|
95
102
|
keys: true,
|
|
96
103
|
vi: true,
|
|
@@ -126,9 +133,37 @@ Options:
|
|
|
126
133
|
inputOnFocus: true,
|
|
127
134
|
style: { fg: 'white', bg: 'black' },
|
|
128
135
|
});
|
|
136
|
+
// Confirmation dialog for revert
|
|
137
|
+
const confirmDialog = blessed.box({
|
|
138
|
+
top: 'center',
|
|
139
|
+
left: 'center',
|
|
140
|
+
width: '38%',
|
|
141
|
+
label: ' Confirm Revert ',
|
|
142
|
+
height: 3,
|
|
143
|
+
content: 'Press ENTER key to confirm revert or ESC to cancel.',
|
|
144
|
+
border: { type: 'line' },
|
|
145
|
+
style: {
|
|
146
|
+
fg: 'yellow',
|
|
147
|
+
bg: 'black',
|
|
148
|
+
border: { fg: 'yellow' }
|
|
149
|
+
},
|
|
150
|
+
hidden: true,
|
|
151
|
+
});
|
|
152
|
+
// Footer box to show shortcuts - aligned with the panes
|
|
153
|
+
const footer = blessed.box({
|
|
154
|
+
bottom: 0,
|
|
155
|
+
left: 0,
|
|
156
|
+
width: '100%',
|
|
157
|
+
height: 1,
|
|
158
|
+
content: chalk_1.default.cyan(' enter') + ': Open file | ' + chalk_1.default.cyan('s') + ': Search | ' + chalk_1.default.cyan('r') + ': Revert file | ' + chalk_1.default.cyan('tab') + ': Switch panes | ' + chalk_1.default.cyan('q/esc') + ': Quit ',
|
|
159
|
+
});
|
|
160
|
+
// Adjust footer to align with the panes
|
|
161
|
+
// Note: We'll adjust this after screen initialization
|
|
129
162
|
screen.append(fileList);
|
|
130
163
|
screen.append(diffView);
|
|
131
164
|
screen.append(searchBox);
|
|
165
|
+
screen.append(confirmDialog);
|
|
166
|
+
screen.append(footer);
|
|
132
167
|
const updateBorders = () => {
|
|
133
168
|
fileList.style.border.fg = screen.focused === fileList ? 'yellow' : 'white';
|
|
134
169
|
diffView.style.border.fg = screen.focused === diffView ? 'yellow' : 'white';
|
|
@@ -145,6 +180,39 @@ Options:
|
|
|
145
180
|
yield updateDiff();
|
|
146
181
|
}), 150); // 150ms debounce
|
|
147
182
|
};
|
|
183
|
+
const handleScroll = (direction) => {
|
|
184
|
+
if (screen.focused === fileList) {
|
|
185
|
+
if (direction === 'up') {
|
|
186
|
+
fileList.up(1);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
fileList.down(1);
|
|
190
|
+
}
|
|
191
|
+
scheduleDiffUpdate();
|
|
192
|
+
screen.render();
|
|
193
|
+
}
|
|
194
|
+
else if (screen.focused === diffView) {
|
|
195
|
+
const scrollAmount = direction === 'up' ? -2 : 2;
|
|
196
|
+
diffView.scroll(scrollAmount);
|
|
197
|
+
screen.render();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
// Remove default wheel listeners to enforce "scroll focused only" behavior
|
|
201
|
+
fileList.removeAllListeners('wheeldown');
|
|
202
|
+
fileList.removeAllListeners('wheelup');
|
|
203
|
+
diffView.removeAllListeners('wheeldown');
|
|
204
|
+
diffView.removeAllListeners('wheelup');
|
|
205
|
+
// Attach custom scroll handlers to widgets (captures wheel even if hovering specific widget)
|
|
206
|
+
// We use widget-level listeners now that screen.mouse is true.
|
|
207
|
+
// We attach to both to ensure the event is caught regardless of where the mouse is.
|
|
208
|
+
// The handleScroll function will then decide WHAT to scroll based on focus.
|
|
209
|
+
fileList.on('wheeldown', () => handleScroll('down'));
|
|
210
|
+
fileList.on('wheelup', () => handleScroll('up'));
|
|
211
|
+
diffView.on('wheeldown', () => handleScroll('down'));
|
|
212
|
+
diffView.on('wheelup', () => handleScroll('up'));
|
|
213
|
+
// Also listen on screen for events that might miss the widgets (margins, borders)
|
|
214
|
+
screen.on('wheeldown', () => handleScroll('down'));
|
|
215
|
+
screen.on('wheelup', () => handleScroll('up'));
|
|
148
216
|
const openInEditor = (filePath) => {
|
|
149
217
|
try {
|
|
150
218
|
if (process.platform === 'win32') {
|
|
@@ -241,7 +309,7 @@ Options:
|
|
|
241
309
|
return `${color}${f.path}{/}`;
|
|
242
310
|
});
|
|
243
311
|
fileList.setItems(items);
|
|
244
|
-
const labelTitle = currentSearchTerm ? `
|
|
312
|
+
const labelTitle = currentSearchTerm ? `Files (${files.length}) - Searching: "${currentSearchTerm}"` : `Files (${files.length})`;
|
|
245
313
|
fileList.setLabel(labelTitle);
|
|
246
314
|
if (items.length > 0) {
|
|
247
315
|
// Restore selection by path if possible
|
|
@@ -255,6 +323,8 @@ Options:
|
|
|
255
323
|
yield updateDiff();
|
|
256
324
|
}
|
|
257
325
|
else {
|
|
326
|
+
// Clear the file list when there are no files
|
|
327
|
+
fileList.clearItems();
|
|
258
328
|
diffView.setContent(currentSearchTerm ? `No files match "${currentSearchTerm}".` : 'No changes detected.');
|
|
259
329
|
diffView.setLabel(' Diff () ');
|
|
260
330
|
}
|
|
@@ -281,6 +351,12 @@ Options:
|
|
|
281
351
|
screen.render();
|
|
282
352
|
fileList.focus();
|
|
283
353
|
}
|
|
354
|
+
else if (!confirmDialog.hidden) {
|
|
355
|
+
// Close the confirmation dialog if it's open
|
|
356
|
+
confirmDialog.hide();
|
|
357
|
+
fileList.focus();
|
|
358
|
+
screen.render();
|
|
359
|
+
}
|
|
284
360
|
else {
|
|
285
361
|
screen.destroy();
|
|
286
362
|
process.exit(0);
|
|
@@ -329,6 +405,43 @@ Options:
|
|
|
329
405
|
openInEditor(selectedFile.path);
|
|
330
406
|
}
|
|
331
407
|
});
|
|
408
|
+
// Handle revert key press
|
|
409
|
+
screen.key(['r'], () => __awaiter(this, void 0, void 0, function* () {
|
|
410
|
+
const selectedIndex = fileList.selected;
|
|
411
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
412
|
+
if (selectedFile) {
|
|
413
|
+
confirmDialog.setContent(`Press SPACE key to confirm revert or ESC to cancel.`);
|
|
414
|
+
confirmDialog.show();
|
|
415
|
+
confirmDialog.focus();
|
|
416
|
+
screen.render();
|
|
417
|
+
}
|
|
418
|
+
}));
|
|
419
|
+
// Handle confirmation dialog response with SPACE key
|
|
420
|
+
confirmDialog.key(['space'], () => __awaiter(this, void 0, void 0, function* () {
|
|
421
|
+
confirmDialog.hide();
|
|
422
|
+
const selectedIndex = fileList.selected;
|
|
423
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
424
|
+
if (selectedFile) {
|
|
425
|
+
try {
|
|
426
|
+
yield gitHandler.revertFile(selectedFile.path);
|
|
427
|
+
console.log(chalk_1.default.green(`File ${selectedFile.path} reverted successfully.`));
|
|
428
|
+
// Refresh the file list after reverting
|
|
429
|
+
yield updateFileList();
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
433
|
+
console.error(chalk_1.default.red(`Error reverting file: ${errorMessage}`));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
fileList.focus();
|
|
437
|
+
screen.render();
|
|
438
|
+
}));
|
|
439
|
+
// Handle cancellation with ESC key
|
|
440
|
+
confirmDialog.key(['escape', 'q'], () => {
|
|
441
|
+
confirmDialog.hide();
|
|
442
|
+
fileList.focus();
|
|
443
|
+
screen.render();
|
|
444
|
+
});
|
|
332
445
|
setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
333
446
|
yield updateFileList();
|
|
334
447
|
}), 5000);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,MAAM,O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
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const status = yield this.git.status();
|
|
35
|
-
const
|
|
35
|
+
const uniqueFiles = new Map();
|
|
36
|
+
// Process each status category and add to map (which prevents duplicates)
|
|
36
37
|
status.modified.forEach(path => {
|
|
37
|
-
|
|
38
|
+
uniqueFiles.set(path, { path, status: 'modified' });
|
|
38
39
|
});
|
|
39
40
|
status.deleted.forEach(path => {
|
|
40
|
-
|
|
41
|
+
// Only add if not already in the map
|
|
42
|
+
if (!uniqueFiles.has(path)) {
|
|
43
|
+
uniqueFiles.set(path, { path, status: 'deleted' });
|
|
44
|
+
}
|
|
41
45
|
});
|
|
42
46
|
status.created.forEach(path => {
|
|
43
|
-
|
|
47
|
+
// Only add if not already in the map
|
|
48
|
+
if (!uniqueFiles.has(path)) {
|
|
49
|
+
uniqueFiles.set(path, { path, status: 'added' });
|
|
50
|
+
}
|
|
44
51
|
});
|
|
45
52
|
status.not_added.forEach(path => {
|
|
46
|
-
|
|
53
|
+
// Only add if not already in the map
|
|
54
|
+
if (!uniqueFiles.has(path)) {
|
|
55
|
+
uniqueFiles.set(path, { path, status: 'unstaged' });
|
|
56
|
+
}
|
|
47
57
|
});
|
|
48
58
|
status.renamed.forEach(r => {
|
|
49
|
-
|
|
59
|
+
// Only add if not already in the map
|
|
60
|
+
if (!uniqueFiles.has(r.to)) {
|
|
61
|
+
uniqueFiles.set(r.to, { path: r.to, status: 'added' });
|
|
62
|
+
}
|
|
50
63
|
});
|
|
51
|
-
const uniqueFiles = new Map();
|
|
52
|
-
files.forEach(f => uniqueFiles.set(f.path, f));
|
|
53
64
|
// Add last modified time for sorting
|
|
54
65
|
const fileArray = Array.from(uniqueFiles.values());
|
|
55
66
|
yield Promise.all(fileArray.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -158,6 +169,17 @@ class GitHandler {
|
|
|
158
169
|
}
|
|
159
170
|
});
|
|
160
171
|
}
|
|
172
|
+
revertFile(filePath) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
try {
|
|
175
|
+
// Restore the specific file to HEAD version
|
|
176
|
+
yield this.git.raw(['restore', filePath]);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
throw new Error(`Could not revert file: ${error}`);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
161
183
|
}
|
|
162
184
|
exports.GitHandler = GitHandler;
|
|
163
185
|
//# sourceMappingURL=git.js.map
|
package/dist/utils/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,2DAA6B;AAQ7B,MAAa,UAAU;IAGrB,YAAY,aAAqB,OAAO,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,GAAG,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEK,MAAM;;YACV,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACtC,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KAAA;IAEK,SAAS;;YACb,MAAM,MAAM,GAAiB,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACrD,MAAM,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,2DAA6B;AAQ7B,MAAa,UAAU;IAGrB,YAAY,aAAqB,OAAO,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,GAAG,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEK,MAAM;;YACV,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC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C;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;KAAA;CACF;AAtKD,gCAsKC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,357 +1,480 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const blessed = require('neo-neo-blessed');
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { spawn } from 'child_process';
|
|
5
|
-
import { GitHandler, FileStatus } from './utils/git';
|
|
6
|
-
import { formatDiffWithDiff2Html } from './utils/diff-formatter';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const args = process.argv.slice(2);
|
|
10
|
-
let repoPath = process.cwd();
|
|
11
|
-
|
|
12
|
-
const showHelp = () => {
|
|
13
|
-
console.log(`
|
|
14
|
-
Usage: diffwatch [path] [options]
|
|
15
|
-
|
|
16
|
-
Arguments:
|
|
17
|
-
path Path to the git repository (default: current directory)
|
|
18
|
-
|
|
19
|
-
Options:
|
|
20
|
-
-h, --help Show help information
|
|
21
|
-
`);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const positionalArgs = [];
|
|
26
|
-
for (let i = 0; i < args.length; i++) {
|
|
27
|
-
if (args[i] === '-h' || args[i] === '--help') {
|
|
28
|
-
showHelp();
|
|
29
|
-
} else if (args[i].startsWith('-')) {
|
|
30
|
-
// Ignore unknown flags or handle them if needed
|
|
31
|
-
} else {
|
|
32
|
-
positionalArgs.push(args[i]);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (positionalArgs.length > 0) {
|
|
37
|
-
repoPath = positionalArgs[0];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
process.chdir(repoPath);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
console.error(`Error: Could not change directory to ${repoPath}`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const gitHandler = new GitHandler(repoPath);
|
|
48
|
-
|
|
49
|
-
if (!(await gitHandler.isRepo())) {
|
|
50
|
-
console.log(chalk.red(`Error: ${repoPath} is not a git repository.`));
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const blessed = require('neo-neo-blessed');
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { GitHandler, FileStatus } from './utils/git';
|
|
6
|
+
import { formatDiffWithDiff2Html } from './utils/diff-formatter';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
let repoPath = process.cwd();
|
|
11
|
+
|
|
12
|
+
const showHelp = () => {
|
|
13
|
+
console.log(`
|
|
14
|
+
Usage: diffwatch [path] [options]
|
|
15
|
+
|
|
16
|
+
Arguments:
|
|
17
|
+
path Path to the git repository (default: current directory)
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
-h, --help Show help information
|
|
21
|
+
`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const positionalArgs = [];
|
|
26
|
+
for (let i = 0; i < args.length; i++) {
|
|
27
|
+
if (args[i] === '-h' || args[i] === '--help') {
|
|
28
|
+
showHelp();
|
|
29
|
+
} else if (args[i].startsWith('-')) {
|
|
30
|
+
// Ignore unknown flags or handle them if needed
|
|
31
|
+
} else {
|
|
32
|
+
positionalArgs.push(args[i]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (positionalArgs.length > 0) {
|
|
37
|
+
repoPath = positionalArgs[0];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
process.chdir(repoPath);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(`Error: Could not change directory to ${repoPath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const gitHandler = new GitHandler(repoPath);
|
|
48
|
+
|
|
49
|
+
if (!(await gitHandler.isRepo())) {
|
|
50
|
+
console.log(chalk.red(`Error: ${repoPath} is not a git repository.`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Force xterm-256color to encourage better mouse support on Windows terminals
|
|
55
|
+
if (process.platform === 'win32' && !process.env.TERM) {
|
|
56
|
+
process.env.TERM = 'xterm-256color';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const screen = blessed.screen({
|
|
60
|
+
smartCSR: true,
|
|
61
|
+
title: 'diffwatch',
|
|
62
|
+
mouse: true,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Explicitly enable mouse tracking
|
|
66
|
+
screen.program.enableMouse();
|
|
67
|
+
|
|
68
|
+
const fileList = blessed.list({
|
|
69
|
+
top: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
width: '30%',
|
|
72
|
+
height: '99%',
|
|
73
|
+
label: 'Files (0)',
|
|
74
|
+
keys: true,
|
|
75
|
+
vi: true,
|
|
76
|
+
mouse: true,
|
|
77
|
+
tags: true,
|
|
78
|
+
scrollbar: {
|
|
79
|
+
ch: ' ',
|
|
80
|
+
track: { bg: 'white' },
|
|
81
|
+
style: { bg: 'blue' },
|
|
82
|
+
},
|
|
83
|
+
style: {
|
|
84
|
+
selected: { fg: 'black', bg: 'white' },
|
|
85
|
+
border: { fg: 'white' },
|
|
86
|
+
},
|
|
87
|
+
border: { type: 'line' },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const diffView = blessed.scrollabletext({
|
|
91
|
+
top: 0,
|
|
92
|
+
left: '30%',
|
|
93
|
+
width: '70%',
|
|
94
|
+
height: '99%',
|
|
95
|
+
label: ' Diff () ',
|
|
96
|
+
keys: true,
|
|
97
|
+
vi: true,
|
|
98
|
+
mouse: true,
|
|
99
|
+
scrollbar: {
|
|
100
|
+
ch: ' ',
|
|
101
|
+
track: { bg: 'white' },
|
|
102
|
+
style: { bg: 'blue' },
|
|
103
|
+
},
|
|
104
|
+
style: {
|
|
105
|
+
border: { fg: 'white' },
|
|
106
|
+
},
|
|
107
|
+
border: { type: 'line' },
|
|
108
|
+
tags: false,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const searchBox = blessed.box({
|
|
112
|
+
top: 'center',
|
|
113
|
+
left: 'center',
|
|
114
|
+
width: '50%',
|
|
115
|
+
height: 3,
|
|
116
|
+
label: ' Search ',
|
|
117
|
+
border: { type: 'line' },
|
|
118
|
+
style: { border: { fg: 'yellow' } },
|
|
119
|
+
hidden: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const searchInput = blessed.textbox({
|
|
123
|
+
parent: searchBox,
|
|
124
|
+
top: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
width: '100%-2',
|
|
127
|
+
height: 1,
|
|
128
|
+
keys: true,
|
|
129
|
+
inputOnFocus: true,
|
|
130
|
+
style: { fg: 'white', bg: 'black' },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Confirmation dialog for revert
|
|
134
|
+
const confirmDialog = blessed.box({
|
|
135
|
+
top: 'center',
|
|
136
|
+
left: 'center',
|
|
137
|
+
width: '38%',
|
|
138
|
+
label: ' Confirm Revert ',
|
|
139
|
+
height: 3,
|
|
140
|
+
content: 'Press ENTER key to confirm revert or ESC to cancel.',
|
|
141
|
+
border: { type: 'line' },
|
|
142
|
+
style: {
|
|
143
|
+
fg: 'yellow',
|
|
144
|
+
bg: 'black',
|
|
145
|
+
border: { fg: 'yellow' }
|
|
146
|
+
},
|
|
147
|
+
hidden: true,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Footer box to show shortcuts - aligned with the panes
|
|
151
|
+
const footer = blessed.box({
|
|
152
|
+
bottom: 0,
|
|
153
|
+
left: 0,
|
|
154
|
+
width: '100%',
|
|
155
|
+
height: 1,
|
|
156
|
+
content: chalk.cyan(' enter') + ': Open file | ' + chalk.cyan('s') + ': Search | ' + chalk.cyan('r') + ': Revert file | ' + chalk.cyan('tab') + ': Switch panes | ' + chalk.cyan('q/esc') + ': Quit ',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Adjust footer to align with the panes
|
|
160
|
+
// Note: We'll adjust this after screen initialization
|
|
161
|
+
|
|
162
|
+
screen.append(fileList);
|
|
163
|
+
screen.append(diffView);
|
|
164
|
+
screen.append(searchBox);
|
|
165
|
+
screen.append(confirmDialog);
|
|
166
|
+
screen.append(footer);
|
|
167
|
+
|
|
168
|
+
const updateBorders = () => {
|
|
169
|
+
fileList.style.border.fg = screen.focused === fileList ? 'yellow' : 'white';
|
|
170
|
+
diffView.style.border.fg = screen.focused === diffView ? 'yellow' : 'white';
|
|
171
|
+
screen.render();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
let currentFiles: FileStatus[] = [];
|
|
175
|
+
let lastSelectedPath: string | null = null;
|
|
176
|
+
let diffUpdateTimeout: NodeJS.Timeout | null = null;
|
|
177
|
+
let currentSearchTerm: string = '';
|
|
178
|
+
|
|
179
|
+
const scheduleDiffUpdate = () => {
|
|
180
|
+
if (diffUpdateTimeout) clearTimeout(diffUpdateTimeout);
|
|
181
|
+
diffUpdateTimeout = setTimeout(async () => {
|
|
182
|
+
await updateDiff();
|
|
183
|
+
}, 150); // 150ms debounce
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const handleScroll = (direction: 'up' | 'down') => {
|
|
187
|
+
if (screen.focused === fileList) {
|
|
188
|
+
if (direction === 'up') {
|
|
189
|
+
fileList.up(1);
|
|
190
|
+
} else {
|
|
191
|
+
fileList.down(1);
|
|
192
|
+
}
|
|
193
|
+
scheduleDiffUpdate();
|
|
194
|
+
screen.render();
|
|
195
|
+
} else if (screen.focused === diffView) {
|
|
196
|
+
const scrollAmount = direction === 'up' ? -2 : 2;
|
|
197
|
+
diffView.scroll(scrollAmount);
|
|
198
|
+
screen.render();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Remove default wheel listeners to enforce "scroll focused only" behavior
|
|
203
|
+
fileList.removeAllListeners('wheeldown');
|
|
204
|
+
fileList.removeAllListeners('wheelup');
|
|
205
|
+
diffView.removeAllListeners('wheeldown');
|
|
206
|
+
diffView.removeAllListeners('wheelup');
|
|
207
|
+
|
|
208
|
+
// Attach custom scroll handlers to widgets (captures wheel even if hovering specific widget)
|
|
209
|
+
// We use widget-level listeners now that screen.mouse is true.
|
|
210
|
+
// We attach to both to ensure the event is caught regardless of where the mouse is.
|
|
211
|
+
// The handleScroll function will then decide WHAT to scroll based on focus.
|
|
212
|
+
|
|
213
|
+
fileList.on('wheeldown', () => handleScroll('down'));
|
|
214
|
+
fileList.on('wheelup', () => handleScroll('up'));
|
|
215
|
+
|
|
216
|
+
diffView.on('wheeldown', () => handleScroll('down'));
|
|
217
|
+
diffView.on('wheelup', () => handleScroll('up'));
|
|
218
|
+
|
|
219
|
+
// Also listen on screen for events that might miss the widgets (margins, borders)
|
|
220
|
+
screen.on('wheeldown', () => handleScroll('down'));
|
|
221
|
+
screen.on('wheelup', () => handleScroll('up'));
|
|
222
|
+
|
|
223
|
+
const openInEditor = (filePath: string) => {
|
|
224
|
+
try {
|
|
225
|
+
if (process.platform === 'win32') {
|
|
226
|
+
// On Windows, use 'start' to open with default program
|
|
227
|
+
spawn('cmd', ['/c', 'start', '', filePath], { stdio: 'ignore', detached: true }).unref();
|
|
228
|
+
} else {
|
|
229
|
+
// On Unix-like systems, try EDITOR, fallback to xdg-open
|
|
230
|
+
const editor = process.env.EDITOR || process.env.VISUAL || 'xdg-open';
|
|
231
|
+
spawn(editor, [filePath], { stdio: 'ignore', detached: true }).unref();
|
|
232
|
+
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error(`Failed to open ${filePath}: ${error}`);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const updateDiff = async () => {
|
|
239
|
+
const selectedIndex = fileList.selected;
|
|
240
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
241
|
+
if (selectedFile) {
|
|
242
|
+
let content = '';
|
|
243
|
+
let label = ` Diff (${selectedFile.path}) `;
|
|
244
|
+
|
|
245
|
+
if (selectedFile.status !== 'unchanged' && selectedFile.status !== 'deleted') {
|
|
246
|
+
const diff = await gitHandler.getDiff(selectedFile.path);
|
|
247
|
+
content = formatDiffWithDiff2Html(diff, currentSearchTerm);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!content && selectedFile.status !== 'deleted') {
|
|
251
|
+
content = await gitHandler.getFileContent(selectedFile.path);
|
|
252
|
+
// Highlight search term in full content
|
|
253
|
+
if (currentSearchTerm) {
|
|
254
|
+
const regex = new RegExp(`(${currentSearchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi');
|
|
255
|
+
content = content.replace(regex, `\x1b[43m\x1b[30m$1\x1b[0m`);
|
|
256
|
+
}
|
|
257
|
+
label = ` File (${selectedFile.path}) `;
|
|
258
|
+
} else if (!content && selectedFile.status === 'deleted') {
|
|
259
|
+
content = chalk.red('File was deleted.');
|
|
260
|
+
label = ` Diff (${selectedFile.path}) `;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const currentContent = diffView.content;
|
|
264
|
+
const currentLabel = diffView.label;
|
|
265
|
+
|
|
266
|
+
// Only update if content or label changed to reduce flickering
|
|
267
|
+
if (content !== currentContent || label !== currentLabel) {
|
|
268
|
+
const savedScroll = diffView.scrollTop;
|
|
269
|
+
const isNewFile = selectedFile.path !== lastSelectedPath;
|
|
270
|
+
|
|
271
|
+
diffView.setContent(content);
|
|
272
|
+
diffView.setLabel(label);
|
|
273
|
+
|
|
274
|
+
if (isNewFile) {
|
|
275
|
+
diffView.scrollTo(0);
|
|
276
|
+
} else {
|
|
277
|
+
diffView.scrollTop = savedScroll;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
lastSelectedPath = selectedFile.path;
|
|
281
|
+
} else {
|
|
282
|
+
const newContent = 'Select a file to view diff.';
|
|
283
|
+
const newLabel = ' Diff () ';
|
|
284
|
+
if (diffView.content !== newContent || diffView.label !== newLabel) {
|
|
285
|
+
diffView.setContent(newContent);
|
|
286
|
+
diffView.setLabel(newLabel);
|
|
287
|
+
diffView.scrollTo(0);
|
|
288
|
+
}
|
|
289
|
+
lastSelectedPath = null;
|
|
290
|
+
}
|
|
291
|
+
screen.render();
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const updateFileList = async () => {
|
|
295
|
+
// Preserve selected file path and scroll positions
|
|
296
|
+
const selectedPath = currentFiles[fileList.selected]?.path;
|
|
297
|
+
const diffScroll = diffView.scrollTop;
|
|
298
|
+
|
|
299
|
+
let files: FileStatus[];
|
|
300
|
+
|
|
301
|
+
if (currentSearchTerm) {
|
|
302
|
+
files = await gitHandler.searchFiles(currentSearchTerm);
|
|
303
|
+
} else {
|
|
304
|
+
files = await gitHandler.getStatus();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
currentFiles = files;
|
|
308
|
+
|
|
309
|
+
const items = files.map(f => {
|
|
310
|
+
let color = '{white-fg}';
|
|
311
|
+
if (f.status === 'added') color = '{green-fg}';
|
|
312
|
+
else if (f.status === 'deleted') color = '{red-fg}';
|
|
313
|
+
else if (f.status === 'modified') color = '{blue-fg}';
|
|
314
|
+
else if (f.status === 'unstaged') color = '{white-fg}';
|
|
315
|
+
else if (f.status === 'unchanged') color = '{grey-fg}';
|
|
316
|
+
|
|
317
|
+
return `${color}${f.path}{/}`;
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
fileList.setItems(items);
|
|
321
|
+
|
|
322
|
+
const labelTitle = currentSearchTerm ? `Files (${files.length}) - Searching: "${currentSearchTerm}"` : `Files (${files.length})`;
|
|
323
|
+
fileList.setLabel(labelTitle);
|
|
324
|
+
|
|
325
|
+
if (items.length > 0) {
|
|
326
|
+
// Restore selection by path if possible
|
|
327
|
+
const newSelectedIndex = selectedPath ? currentFiles.findIndex(f => f.path === selectedPath) : -1;
|
|
328
|
+
fileList.select(newSelectedIndex >= 0 ? newSelectedIndex : 0);
|
|
329
|
+
// Cancel any pending diff update and update immediately
|
|
330
|
+
if (diffUpdateTimeout) {
|
|
331
|
+
clearTimeout(diffUpdateTimeout);
|
|
332
|
+
diffUpdateTimeout = null;
|
|
333
|
+
}
|
|
334
|
+
await updateDiff();
|
|
335
|
+
} else {
|
|
336
|
+
// Clear the file list when there are no files
|
|
337
|
+
fileList.clearItems();
|
|
338
|
+
diffView.setContent(currentSearchTerm ? `No files match "${currentSearchTerm}".` : 'No changes detected.');
|
|
339
|
+
diffView.setLabel(' Diff () ');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Restore scroll positions if reasonably possible (reset if list changed drastically)
|
|
343
|
+
// Actually, if we filter, the scroll position might be invalid.
|
|
344
|
+
// Ideally we keep it 0 if it was 0 or just let the select() call handle scrolling to the item.
|
|
345
|
+
// The previous implementation blindly restored scrollTop.
|
|
346
|
+
// If the list shrunk, select() should have brought it into view.
|
|
347
|
+
// We only explicitly restore if items.length > 0
|
|
348
|
+
// But setting scroll to previous value might be wrong if the list is now shorter.
|
|
349
|
+
// Safe to only restore diffView scroll as it depends on content, fileList is handled by select.
|
|
350
|
+
|
|
351
|
+
diffView.scrollTop = diffScroll;
|
|
352
|
+
|
|
353
|
+
screen.render();
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
fileList.on('select item', () => {
|
|
357
|
+
scheduleDiffUpdate();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
fileList.key(['up', 'down'], () => {
|
|
361
|
+
scheduleDiffUpdate();
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
screen.key(['escape', 'q', 'C-c'], () => {
|
|
365
|
+
if (!searchBox.hidden) {
|
|
366
|
+
searchBox.hide();
|
|
367
|
+
screen.render();
|
|
368
|
+
fileList.focus();
|
|
369
|
+
} else if (!confirmDialog.hidden) {
|
|
370
|
+
// Close the confirmation dialog if it's open
|
|
371
|
+
confirmDialog.hide();
|
|
372
|
+
fileList.focus();
|
|
373
|
+
screen.render();
|
|
374
|
+
} else {
|
|
375
|
+
screen.destroy();
|
|
376
|
+
process.exit(0);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
screen.key(['s'], () => {
|
|
381
|
+
searchBox.show();
|
|
382
|
+
searchBox.setFront();
|
|
383
|
+
searchInput.setValue(currentSearchTerm);
|
|
384
|
+
searchInput.focus();
|
|
385
|
+
screen.render();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
searchInput.on('submit', async (value: string) => {
|
|
389
|
+
currentSearchTerm = (value || '').trim();
|
|
390
|
+
searchBox.hide();
|
|
391
|
+
fileList.focus();
|
|
392
|
+
// Force immediate update
|
|
393
|
+
await updateFileList();
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
searchInput.on('cancel', () => {
|
|
397
|
+
searchBox.hide();
|
|
398
|
+
fileList.focus();
|
|
399
|
+
screen.render();
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
screen.key(['tab'], () => {
|
|
403
|
+
if (screen.focused === fileList) {
|
|
404
|
+
diffView.focus();
|
|
405
|
+
} else {
|
|
406
|
+
fileList.focus();
|
|
407
|
+
}
|
|
408
|
+
updateBorders();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
screen.key(['left'], () => {
|
|
412
|
+
fileList.focus();
|
|
413
|
+
updateBorders();
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
screen.key(['right'], () => {
|
|
417
|
+
diffView.focus();
|
|
418
|
+
updateBorders();
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
screen.key(['enter'], () => {
|
|
422
|
+
const selectedIndex = fileList.selected;
|
|
423
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
424
|
+
if (selectedFile) {
|
|
425
|
+
openInEditor(selectedFile.path);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// Handle revert key press
|
|
430
|
+
screen.key(['r'], async () => {
|
|
431
|
+
const selectedIndex = fileList.selected;
|
|
432
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
433
|
+
if (selectedFile) {
|
|
434
|
+
confirmDialog.setContent(`Press SPACE key to confirm revert or ESC to cancel.`);
|
|
435
|
+
confirmDialog.show();
|
|
436
|
+
confirmDialog.focus();
|
|
437
|
+
screen.render();
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// Handle confirmation dialog response with SPACE key
|
|
442
|
+
confirmDialog.key(['space'], async () => {
|
|
443
|
+
confirmDialog.hide();
|
|
444
|
+
const selectedIndex = fileList.selected;
|
|
445
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
446
|
+
if (selectedFile) {
|
|
447
|
+
try {
|
|
448
|
+
await gitHandler.revertFile(selectedFile.path);
|
|
449
|
+
console.log(chalk.green(`File ${selectedFile.path} reverted successfully.`));
|
|
450
|
+
// Refresh the file list after reverting
|
|
451
|
+
await updateFileList();
|
|
452
|
+
} catch (error) {
|
|
453
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
454
|
+
console.error(chalk.red(`Error reverting file: ${errorMessage}`));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
fileList.focus();
|
|
458
|
+
screen.render();
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// Handle cancellation with ESC key
|
|
462
|
+
confirmDialog.key(['escape', 'q'], () => {
|
|
463
|
+
confirmDialog.hide();
|
|
464
|
+
fileList.focus();
|
|
465
|
+
screen.render();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
setInterval(async () => {
|
|
469
|
+
await updateFileList();
|
|
470
|
+
}, 5000);
|
|
471
|
+
|
|
472
|
+
await updateFileList();
|
|
473
|
+
fileList.focus();
|
|
474
|
+
updateBorders();
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
main().catch(err => {
|
|
478
|
+
console.error(err);
|
|
479
|
+
process.exit(1);
|
|
480
|
+
});
|
package/src/utils/git.ts
CHANGED
|
@@ -24,31 +24,41 @@ export class GitHandler {
|
|
|
24
24
|
|
|
25
25
|
async getStatus(): Promise<FileStatus[]> {
|
|
26
26
|
const status: StatusResult = await this.git.status();
|
|
27
|
-
const
|
|
27
|
+
const uniqueFiles = new Map<string, FileStatus>();
|
|
28
28
|
|
|
29
|
+
// Process each status category and add to map (which prevents duplicates)
|
|
29
30
|
status.modified.forEach(path => {
|
|
30
|
-
|
|
31
|
+
uniqueFiles.set(path, { path, status: 'modified' });
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
status.deleted.forEach(path => {
|
|
34
|
-
|
|
35
|
+
// Only add if not already in the map
|
|
36
|
+
if (!uniqueFiles.has(path)) {
|
|
37
|
+
uniqueFiles.set(path, { path, status: 'deleted' });
|
|
38
|
+
}
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
status.created.forEach(path => {
|
|
38
|
-
|
|
42
|
+
// Only add if not already in the map
|
|
43
|
+
if (!uniqueFiles.has(path)) {
|
|
44
|
+
uniqueFiles.set(path, { path, status: 'added' });
|
|
45
|
+
}
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
status.not_added.forEach(path => {
|
|
42
|
-
|
|
49
|
+
// Only add if not already in the map
|
|
50
|
+
if (!uniqueFiles.has(path)) {
|
|
51
|
+
uniqueFiles.set(path, { path, status: 'unstaged' });
|
|
52
|
+
}
|
|
43
53
|
});
|
|
44
54
|
|
|
45
55
|
status.renamed.forEach(r => {
|
|
46
|
-
|
|
56
|
+
// Only add if not already in the map
|
|
57
|
+
if (!uniqueFiles.has(r.to)) {
|
|
58
|
+
uniqueFiles.set(r.to, { path: r.to, status: 'added' });
|
|
59
|
+
}
|
|
47
60
|
});
|
|
48
61
|
|
|
49
|
-
const uniqueFiles = new Map<string, FileStatus>();
|
|
50
|
-
files.forEach(f => uniqueFiles.set(f.path, f));
|
|
51
|
-
|
|
52
62
|
// Add last modified time for sorting
|
|
53
63
|
const fileArray = Array.from(uniqueFiles.values());
|
|
54
64
|
await Promise.all(fileArray.map(async (f) => {
|
|
@@ -154,4 +164,13 @@ export class GitHandler {
|
|
|
154
164
|
return `Error reading file: ${error}`;
|
|
155
165
|
}
|
|
156
166
|
}
|
|
167
|
+
|
|
168
|
+
async revertFile(filePath: string): Promise<void> {
|
|
169
|
+
try {
|
|
170
|
+
// Restore the specific file to HEAD version
|
|
171
|
+
await this.git.raw(['restore', filePath]);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw new Error(`Could not revert file: ${error}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
157
176
|
}
|