edit button now reads the file to get newline breaks instead! #7647
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Feb 24, 2026 at 17:59 UTC
68c5861fb6cb3a4febdfdd0a5fa5637f1afde8d9
2 files changed
+46
-11
views/default.handlebars
+25
-7
@@ -11782,19 +11782,37 @@
11782
if (gdownloadFile.tag == 'viewer') {
11783
// View the file in the dialog box
11784
setDialogMode(4, EscapeHtml(gdownloadFile.file), 3, p13editSaveBack, null, gdownloadFile.file);
11785
- if (isWindowsNode(currentNode)){
11786
- d4EditLineBreakVal = 0; // Windows (CR LF)
11787
- } else if (isMacNode(currentNode)) {
11788
- d4EditLineBreakVal = 2; // Mac (CR)
11789
- } else {
11790
- d4EditLineBreakVal = 1; // Linux (LF)
11791
- }
11785
d4ToggleLineBreak(true);
11786
QV('d4EncodingButton', true);
11787
QV('d4LineBreakButton', true);
11788
QS('dialog').width = 'auto';
11789
QS('dialog').bottom = '80px';
11790
QS('dialog').top = QS('dialog').left = QS('dialog').right = '100px';
11791
+ const crlf = (gdownloadFile.data.match(/\r\n/g) || []).length;
11792
+ const cr = (gdownloadFile.data.match(/\r(?!\n)/g) || []).length;
11793
+ const lf = (gdownloadFile.data.match(/(?<!\r)\n/g) || []).length;
11794
+ let type;
11795
+ if (crlf > 0 && cr === 0 && lf === 0) {
11796
+ type = 'crlf';
11797
+ } else if (lf > 0 && crlf === 0 && cr === 0) {
11798
+ type = 'lf';
11799
+ } else if (cr > 0 && crlf === 0 && lf === 0) {
11800
+ type = 'cr';
11801
+ } else {
11802
+ // Mixed - pick dominant
11803
+ const dominant = Math.max(crlf, cr, lf);
11804
+ if (dominant === crlf) type = 'crlf';
11805
+ else if (dominant === lf) type = 'lf';
11806
+ else type = 'cr';
11807
+ }
11808
+ if (type === 'crlf') {
11809
+ d4EditLineBreakVal = 0; // Windows (CR LF)
11810
+ } else if (type === 'lf') {
11811
+ d4EditLineBreakVal = 1; // Linux (LF)
11812
+ } else {
11813
+ d4EditLineBreakVal = 2; // Mac (CR)
11814
+ }
11815
+ d4ToggleLineBreak(true);
11816
if (d4EditEncodingVal == 1) {
11817
Q('d4editorarea').value = decode_utf8(gdownloadFile.data); // UTF8 Encoding
11818
} else {
views/default3.handlebars
+21
-4
@@ -12827,12 +12827,29 @@
12827
setModalContent('xxAddAgent', EscapeHtml(gdownloadFile.file), 4, 'extra-large');
12828
var file = gdownloadFile.file;
12829
showModal('xxAddAgentModal', 'idx_dlgOkButton', () => p13editSaveBack(3, file));
12830
- if (isWindowsNode(currentNode)){
12831
- d4EditLineBreakVal = 0; // Windows (CR LF)
12832
- } else if (isMacNode(currentNode)) {
12833
- d4EditLineBreakVal = 2; // Mac (CR)
12830
+ const crlf = (gdownloadFile.data.match(/\r\n/g) || []).length;
12831
+ const cr = (gdownloadFile.data.match(/\r(?!\n)/g) || []).length;
12832
+ const lf = (gdownloadFile.data.match(/(?<!\r)\n/g) || []).length;
12833
+ let type;
12834
+ if (crlf > 0 && cr === 0 && lf === 0) {
12835
+ type = 'crlf';
12836
+ } else if (lf > 0 && crlf === 0 && cr === 0) {
12837
+ type = 'lf';
12838
+ } else if (cr > 0 && crlf === 0 && lf === 0) {
12839
+ type = 'cr';
12840
} else {
12841
+ // Mixed - pick dominant
12842
+ const dominant = Math.max(crlf, cr, lf);
12843
+ if (dominant === crlf) type = 'crlf';
12844
+ else if (dominant === lf) type = 'lf';
12845
+ else type = 'cr';
12846
+ }
12847
+ if (type === 'crlf') {
12848
+ d4EditLineBreakVal = 0; // Windows (CR LF)
12849
+ } else if (type === 'lf') {
12850
d4EditLineBreakVal = 1; // Linux (LF)
12851
+ } else {
12852
+ d4EditLineBreakVal = 2; // Mac (CR)
12853
}
12854
d4ToggleLineBreak(true);
12855
QV('d4EncodingButton', true);