Fossil SCM
Correct handling of keyboard-based diff scrolling.
Commit
0ef89983b848018228986d6522d76335b85724ff5f831462eb054e9ddbb6dece
Parent
564a64027a12de7…
1 file changed
+19
-7
+19
-7
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -707,26 +707,38 @@ | ||
| 707 | 707 | } |
| 708 | 708 | return this; |
| 709 | 709 | } |
| 710 | 710 | diff.$txtCols = diff.querySelectorAll('td.difftxt'); |
| 711 | 711 | diff.$txtPres = diff.querySelectorAll('td.difftxt pre'); |
| 712 | - diff.$txtPres.forEach(function(e){ | |
| 713 | - if(!unifiedDiffs && !e.classList.contains('scroller')){ | |
| 714 | - D.addClass(e, 'scroller'); | |
| 715 | - e.addEventListener('scroll', scrollLeft, false); | |
| 716 | - } | |
| 717 | - }); | |
| 718 | 712 | if(!unifiedDiffs){ |
| 713 | + diff.$txtPres.forEach(function(e){ | |
| 714 | + if(!e.classList.contains('scroller')){ | |
| 715 | + D.addClass(e, 'scroller'); | |
| 716 | + e.addEventListener('scroll', scrollLeft, false); | |
| 717 | + } | |
| 718 | + }); | |
| 719 | 719 | diff.tabIndex = 0; |
| 720 | 720 | if(!diff.classList.contains('scroller')){ |
| 721 | + /* Keyboard-based scrolling requires special-case handling to | |
| 722 | + ensure that we scroll the proper side of the diff when sync | |
| 723 | + is off. */ | |
| 721 | 724 | D.addClass(diff, 'scroller'); |
| 722 | 725 | diff.addEventListener('keydown', function(e){ |
| 723 | 726 | const len = keycodes[e.keyCode]; |
| 724 | 727 | if( !len ) return false; |
| 725 | - this.$txtPres[0].scrollLeft += len; | |
| 728 | + if( useSync() ){ | |
| 729 | + this.$txtPres[0].scrollLeft += len; | |
| 730 | + }else if( diff.$preCurrent ){ | |
| 731 | + this.$preCurrent.scrollLeft += len; | |
| 732 | + } | |
| 726 | 733 | return false; |
| 727 | 734 | }, false); |
| 735 | + diff.$txtPres.forEach((e)=>{ | |
| 736 | + e.addEventListener('click', function(ev){ | |
| 737 | + diff.$preCurrent = this /* NOT ev.target, which is probably a child element */; | |
| 738 | + }, false); | |
| 739 | + }) | |
| 728 | 740 | } |
| 729 | 741 | } |
| 730 | 742 | return this; |
| 731 | 743 | } |
| 732 | 744 | window.fossil.page.tweakSbsDiffs = function(){ |
| 733 | 745 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -707,26 +707,38 @@ | |
| 707 | } |
| 708 | return this; |
| 709 | } |
| 710 | diff.$txtCols = diff.querySelectorAll('td.difftxt'); |
| 711 | diff.$txtPres = diff.querySelectorAll('td.difftxt pre'); |
| 712 | diff.$txtPres.forEach(function(e){ |
| 713 | if(!unifiedDiffs && !e.classList.contains('scroller')){ |
| 714 | D.addClass(e, 'scroller'); |
| 715 | e.addEventListener('scroll', scrollLeft, false); |
| 716 | } |
| 717 | }); |
| 718 | if(!unifiedDiffs){ |
| 719 | diff.tabIndex = 0; |
| 720 | if(!diff.classList.contains('scroller')){ |
| 721 | D.addClass(diff, 'scroller'); |
| 722 | diff.addEventListener('keydown', function(e){ |
| 723 | const len = keycodes[e.keyCode]; |
| 724 | if( !len ) return false; |
| 725 | this.$txtPres[0].scrollLeft += len; |
| 726 | return false; |
| 727 | }, false); |
| 728 | } |
| 729 | } |
| 730 | return this; |
| 731 | } |
| 732 | window.fossil.page.tweakSbsDiffs = function(){ |
| 733 |
| --- src/fossil.diff.js | |
| +++ src/fossil.diff.js | |
| @@ -707,26 +707,38 @@ | |
| 707 | } |
| 708 | return this; |
| 709 | } |
| 710 | diff.$txtCols = diff.querySelectorAll('td.difftxt'); |
| 711 | diff.$txtPres = diff.querySelectorAll('td.difftxt pre'); |
| 712 | if(!unifiedDiffs){ |
| 713 | diff.$txtPres.forEach(function(e){ |
| 714 | if(!e.classList.contains('scroller')){ |
| 715 | D.addClass(e, 'scroller'); |
| 716 | e.addEventListener('scroll', scrollLeft, false); |
| 717 | } |
| 718 | }); |
| 719 | diff.tabIndex = 0; |
| 720 | if(!diff.classList.contains('scroller')){ |
| 721 | /* Keyboard-based scrolling requires special-case handling to |
| 722 | ensure that we scroll the proper side of the diff when sync |
| 723 | is off. */ |
| 724 | D.addClass(diff, 'scroller'); |
| 725 | diff.addEventListener('keydown', function(e){ |
| 726 | const len = keycodes[e.keyCode]; |
| 727 | if( !len ) return false; |
| 728 | if( useSync() ){ |
| 729 | this.$txtPres[0].scrollLeft += len; |
| 730 | }else if( diff.$preCurrent ){ |
| 731 | this.$preCurrent.scrollLeft += len; |
| 732 | } |
| 733 | return false; |
| 734 | }, false); |
| 735 | diff.$txtPres.forEach((e)=>{ |
| 736 | e.addEventListener('click', function(ev){ |
| 737 | diff.$preCurrent = this /* NOT ev.target, which is probably a child element */; |
| 738 | }, false); |
| 739 | }) |
| 740 | } |
| 741 | } |
| 742 | return this; |
| 743 | } |
| 744 | window.fossil.page.tweakSbsDiffs = function(){ |
| 745 |