Fossil SCM

Propagate the default value of diff_context_lines() through to window.fossil.config.diffContextLines for use by the jchunk UI. Per /chat discussion, jchunk will load 3x that many lines of context per button click.

stephan 2021-09-10 23:12 diff-js-refactoring
Commit 8f84424fff2a9aef7042145bf753cee404336eb0e2d82824b0ec32ddb705da3e
--- src/builtin.c
+++ src/builtin.c
@@ -623,10 +623,12 @@
623623
CX("projectCode: %!j,\n", zName);
624624
fossil_free(zName);
625625
CX("/* Length of UUID hashes for display purposes. */");
626626
CX("hashDigits: %d, hashDigitsUrl: %d,\n",
627627
hash_digits(0), hash_digits(1));
628
+ CX("diffContextLines: %d,\n",
629
+ diff_context_lines(0));
628630
CX("editStateMarkers: {"
629631
"/*Symbolic markers to denote certain edit states.*/"
630632
"isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n");
631633
CX("confirmerButtonTicks: 3 "
632634
"/*default fossil.confirmer tick count.*/,\n");
633635
--- src/builtin.c
+++ src/builtin.c
@@ -623,10 +623,12 @@
623 CX("projectCode: %!j,\n", zName);
624 fossil_free(zName);
625 CX("/* Length of UUID hashes for display purposes. */");
626 CX("hashDigits: %d, hashDigitsUrl: %d,\n",
627 hash_digits(0), hash_digits(1));
 
 
628 CX("editStateMarkers: {"
629 "/*Symbolic markers to denote certain edit states.*/"
630 "isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n");
631 CX("confirmerButtonTicks: 3 "
632 "/*default fossil.confirmer tick count.*/,\n");
633
--- src/builtin.c
+++ src/builtin.c
@@ -623,10 +623,12 @@
623 CX("projectCode: %!j,\n", zName);
624 fossil_free(zName);
625 CX("/* Length of UUID hashes for display purposes. */");
626 CX("hashDigits: %d, hashDigitsUrl: %d,\n",
627 hash_digits(0), hash_digits(1));
628 CX("diffContextLines: %d,\n",
629 diff_context_lines(0));
630 CX("editStateMarkers: {"
631 "/*Symbolic markers to denote certain edit states.*/"
632 "isNew:'[+]', isModified:'[*]', isDeleted:'[-]'},\n");
633 CX("confirmerButtonTicks: 3 "
634 "/*default fossil.confirmer tick count.*/,\n");
635
+11 -4
--- src/diff.c
+++ src/diff.c
@@ -2577,16 +2577,23 @@
25772577
}
25782578
}
25792579
25802580
/*
25812581
** Extract the number of lines of context from diffFlags. Supply an
2582
-** appropriate default if no context width is specified.
2582
+** appropriate default if no context width is specified. If pCfg is
2583
+** NULL then the compile-time default is used (which gets propagated
2584
+** to JS-side state by certain pages).
25832585
*/
25842586
int diff_context_lines(DiffConfig *pCfg){
2585
- int n = pCfg->nContext;
2586
- if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5;
2587
- return n;
2587
+ const int dflt = 5;
2588
+ if(pCfg!=0){
2589
+ int n = pCfg->nContext;
2590
+ if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = dflt;
2591
+ return n;
2592
+ }else{
2593
+ return dflt;
2594
+ }
25882595
}
25892596
25902597
/*
25912598
** Extract the width of columns for side-by-side diff. Supply an
25922599
** appropriate default if no width is given.
25932600
--- src/diff.c
+++ src/diff.c
@@ -2577,16 +2577,23 @@
2577 }
2578 }
2579
2580 /*
2581 ** Extract the number of lines of context from diffFlags. Supply an
2582 ** appropriate default if no context width is specified.
 
 
2583 */
2584 int diff_context_lines(DiffConfig *pCfg){
2585 int n = pCfg->nContext;
2586 if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5;
2587 return n;
 
 
 
 
 
2588 }
2589
2590 /*
2591 ** Extract the width of columns for side-by-side diff. Supply an
2592 ** appropriate default if no width is given.
2593
--- src/diff.c
+++ src/diff.c
@@ -2577,16 +2577,23 @@
2577 }
2578 }
2579
2580 /*
2581 ** Extract the number of lines of context from diffFlags. Supply an
2582 ** appropriate default if no context width is specified. If pCfg is
2583 ** NULL then the compile-time default is used (which gets propagated
2584 ** to JS-side state by certain pages).
2585 */
2586 int diff_context_lines(DiffConfig *pCfg){
2587 const int dflt = 5;
2588 if(pCfg!=0){
2589 int n = pCfg->nContext;
2590 if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = dflt;
2591 return n;
2592 }else{
2593 return dflt;
2594 }
2595 }
2596
2597 /*
2598 ** Extract the width of columns for side-by-side diff. Supply an
2599 ** appropriate default if no width is given.
2600
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -23,11 +23,14 @@
2323
window.fossil.onPageLoad(function(){
2424
const F = window.fossil, D = F.dom;
2525
const Diff = F.diff = {
2626
e:{/*certain cached DOM elements*/},
2727
config: {
28
- chunkLoadLines: 30 /* TODO: 3x default context diff value */,
28
+ chunkLoadLines: (
29
+ F.config.diffContextLines * 3
30
+ /*per /chat discussion*/
31
+ ) || 20,
2932
chunkFetch: {
3033
/* Default callack handlers for Diff.fetchArtifactChunk(),
3134
unless overridden by options passeed to that function. */
3235
beforesend: function(){},
3336
aftersend: function(){},
@@ -418,12 +421,11 @@
418421
}
419422
e.innerHTML = content.join('');
420423
});
421424
}
422425
423
- if(1){
424
- // Add blank lines in (.diffsep>pre)
426
+ if(1){// Add blank lines in (.diffsep>pre)
425427
const selector = '.diffsep > pre';
426428
td = tr.querySelector(selector);
427429
for(i = 0; i < lineno.length; ++i) lineno[i] = '';
428430
const blanks = lineno.join('\n')+'\n';
429431
const content = [td.innerHTML];
430432
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -23,11 +23,14 @@
23 window.fossil.onPageLoad(function(){
24 const F = window.fossil, D = F.dom;
25 const Diff = F.diff = {
26 e:{/*certain cached DOM elements*/},
27 config: {
28 chunkLoadLines: 30 /* TODO: 3x default context diff value */,
 
 
 
29 chunkFetch: {
30 /* Default callack handlers for Diff.fetchArtifactChunk(),
31 unless overridden by options passeed to that function. */
32 beforesend: function(){},
33 aftersend: function(){},
@@ -418,12 +421,11 @@
418 }
419 e.innerHTML = content.join('');
420 });
421 }
422
423 if(1){
424 // Add blank lines in (.diffsep>pre)
425 const selector = '.diffsep > pre';
426 td = tr.querySelector(selector);
427 for(i = 0; i < lineno.length; ++i) lineno[i] = '';
428 const blanks = lineno.join('\n')+'\n';
429 const content = [td.innerHTML];
430
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -23,11 +23,14 @@
23 window.fossil.onPageLoad(function(){
24 const F = window.fossil, D = F.dom;
25 const Diff = F.diff = {
26 e:{/*certain cached DOM elements*/},
27 config: {
28 chunkLoadLines: (
29 F.config.diffContextLines * 3
30 /*per /chat discussion*/
31 ) || 20,
32 chunkFetch: {
33 /* Default callack handlers for Diff.fetchArtifactChunk(),
34 unless overridden by options passeed to that function. */
35 beforesend: function(){},
36 aftersend: function(){},
@@ -418,12 +421,11 @@
421 }
422 e.innerHTML = content.join('');
423 });
424 }
425
426 if(1){// Add blank lines in (.diffsep>pre)
 
427 const selector = '.diffsep > pre';
428 td = tr.querySelector(selector);
429 for(i = 0; i < lineno.length; ++i) lineno[i] = '';
430 const blanks = lineno.join('\n')+'\n';
431 const content = [td.innerHTML];
432

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button