@fresh-editor/fresh-editor 0.1.13 → 0.1.14
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/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/plugins/buffer_modified.ts +34 -0
- package/plugins/lib/fresh.d.ts +9 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"hasInstallScript": true,
|
|
24
24
|
"license": "GPL-2.0",
|
|
25
25
|
"name": "@fresh-editor/fresh-editor",
|
|
26
|
-
"version": "0.1.
|
|
26
|
+
"version": "0.1.14"
|
|
27
27
|
},
|
|
28
28
|
"node_modules/@isaacs/balanced-match": {
|
|
29
29
|
"engines": {
|
|
@@ -896,5 +896,5 @@
|
|
|
896
896
|
}
|
|
897
897
|
},
|
|
898
898
|
"requires": true,
|
|
899
|
-
"version": "0.1.
|
|
899
|
+
"version": "0.1.14"
|
|
900
900
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"artifactDownloadUrl": "https://github.com/sinelaw/fresh/releases/download/v0.1.
|
|
2
|
+
"artifactDownloadUrl": "https://github.com/sinelaw/fresh/releases/download/v0.1.14",
|
|
3
3
|
"author": "Noam Lewis",
|
|
4
4
|
"bin": {
|
|
5
5
|
"fresh": "run-fresh.js"
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"zipExt": ".tar.xz"
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
|
-
"version": "0.1.
|
|
95
|
+
"version": "0.1.14",
|
|
96
96
|
"volta": {
|
|
97
97
|
"node": "18.14.1",
|
|
98
98
|
"npm": "9.5.0"
|
|
@@ -94,6 +94,38 @@ function markLinesModified(bufferId: number, startLine: number, endLine: number)
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
function reapplyIndicatorsFromDiff(bufferId: number): void {
|
|
98
|
+
const diff = editor.getBufferSavedDiff(bufferId);
|
|
99
|
+
if (!diff) return;
|
|
100
|
+
|
|
101
|
+
// If buffer matches saved snapshot, clear everything.
|
|
102
|
+
if (diff.equal) {
|
|
103
|
+
editor.clearLineIndicators(bufferId, NAMESPACE);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const ranges = diff.line_ranges;
|
|
108
|
+
// If line info is unavailable, leave existing indicators (best effort).
|
|
109
|
+
if (!ranges) return;
|
|
110
|
+
|
|
111
|
+
// Reset namespace to drop stale indicators outside the changed ranges.
|
|
112
|
+
editor.clearLineIndicators(bufferId, NAMESPACE);
|
|
113
|
+
for (const [start, end] of ranges) {
|
|
114
|
+
for (let line = start; line < end; line++) {
|
|
115
|
+
editor.setLineIndicator(
|
|
116
|
+
bufferId,
|
|
117
|
+
line,
|
|
118
|
+
NAMESPACE,
|
|
119
|
+
SYMBOL,
|
|
120
|
+
COLOR[0],
|
|
121
|
+
COLOR[1],
|
|
122
|
+
COLOR[2],
|
|
123
|
+
PRIORITY
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
97
129
|
// =============================================================================
|
|
98
130
|
// Event Handlers
|
|
99
131
|
// =============================================================================
|
|
@@ -179,6 +211,7 @@ globalThis.onBufferModifiedAfterInsert = function (args: {
|
|
|
179
211
|
// Mark all affected lines (from start_line to end_line inclusive)
|
|
180
212
|
// The indicator markers will automatically track their positions
|
|
181
213
|
markLinesModified(bufferId, args.start_line, args.end_line);
|
|
214
|
+
reapplyIndicatorsFromDiff(bufferId);
|
|
182
215
|
|
|
183
216
|
return true;
|
|
184
217
|
};
|
|
@@ -209,6 +242,7 @@ globalThis.onBufferModifiedAfterDelete = function (args: {
|
|
|
209
242
|
// Mark the line where deletion occurred
|
|
210
243
|
// Markers for deleted lines are automatically cleaned up
|
|
211
244
|
markLinesModified(bufferId, args.start_line, args.start_line);
|
|
245
|
+
reapplyIndicatorsFromDiff(bufferId);
|
|
212
246
|
|
|
213
247
|
return true;
|
|
214
248
|
};
|
package/plugins/lib/fresh.d.ts
CHANGED
|
@@ -123,6 +123,13 @@ interface BufferInfo {
|
|
|
123
123
|
length: number;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/** Diff vs last save for a buffer */
|
|
127
|
+
interface TsBufferSavedDiff {
|
|
128
|
+
equal: boolean;
|
|
129
|
+
byte_ranges: [number, number][];
|
|
130
|
+
line_ranges?: [number, number][] | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
/** Selection range */
|
|
127
134
|
interface SelectionRange {
|
|
128
135
|
/** Start byte position */
|
|
@@ -341,6 +348,8 @@ interface EditorAPI {
|
|
|
341
348
|
* @returns true if process is running, false if not found or exited
|
|
342
349
|
*/
|
|
343
350
|
isProcessRunning(#[bigint] process_id: number): boolean;
|
|
351
|
+
/** Get diff vs last saved snapshot for a buffer */
|
|
352
|
+
getBufferSavedDiff(buffer_id: number): TsBufferSavedDiff | null;
|
|
344
353
|
|
|
345
354
|
// === Buffer Info Queries ===
|
|
346
355
|
/**
|