Skip to content

Commit 6199187

Browse files
QrackEEhansu
authored andcommitted
ADD button to go to 'current' commit.
TODO: improve icon, sync with similar features in other GUI items (cherry picked from commit 88e9b09)
1 parent e6e3f5e commit 6199187

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

src/gitGraphView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ export class GitGraphView extends Disposable {
725725
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>
726726
727727
<label id="showRemoteBranchesControl"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Show Remote Branches</label>
728+
<div id="currentBtn" title="Current"></div>
728729
<div id="findBtn" title="Find"></div>
729730
<div id="terminalBtn" title="Open a Terminal for this Repository"></div>
730731
<div id="settingsBtn" title="Repository Settings"></div>

web/main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ class GitGraphView {
155155
this.requestLoadRepoInfoAndCommits(false, false);
156156
}
157157

158-
const fetchBtn = document.getElementById('fetchBtn')!, findBtn = document.getElementById('findBtn')!, settingsBtn = document.getElementById('settingsBtn')!, terminalBtn = document.getElementById('terminalBtn')!;
158+
const currentBtn = document.getElementById('currentBtn')!, fetchBtn = document.getElementById('fetchBtn')!, findBtn = document.getElementById('findBtn')!, settingsBtn = document.getElementById('settingsBtn')!, terminalBtn = document.getElementById('terminalBtn')!;
159+
currentBtn.innerHTML = SVG_ICONS.current;
160+
currentBtn.addEventListener('click', () => {
161+
if (this.commitHead) {
162+
this.scrollToCommit(this.commitHead, true, true);
163+
}
164+
});
159165
fetchBtn.title = 'Fetch' + (this.config.fetchAndPrune ? ' & Prune' : '') + ' from Remote(s)';
160166
fetchBtn.innerHTML = SVG_ICONS.download;
161167
fetchBtn.addEventListener('click', () => this.fetchFromRemotesAction());

web/styles/main.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ body.tagLabelsRightAligned .gitRef.tag{
827827
max-width:40vw;
828828
}
829829

830-
#findBtn, #terminalBtn, #settingsBtn, #fetchBtn, #refreshBtn{
830+
#currentBtn, #findBtn, #terminalBtn, #settingsBtn, #fetchBtn, #refreshBtn{
831831
position:absolute;
832832
top:50%;
833833
width:20px;
@@ -837,6 +837,9 @@ body.tagLabelsRightAligned .gitRef.tag{
837837
-webkit-user-select:none;
838838
user-select:none;
839839
}
840+
#currentBtn{
841+
right:130px;
842+
}
840843
#findBtn{
841844
right:100px;
842845
}
@@ -856,25 +859,25 @@ body.tagLabelsRightAligned .gitRef.tag{
856859
#refreshBtn.refreshing{
857860
cursor:default;
858861
}
859-
#findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg, #refreshBtn svg{
862+
#currentBtn svg, #findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg, #refreshBtn svg{
860863
position:absolute;
861864
fill:var(--vscode-editor-foreground);
862865
opacity:0.8;
863866
stroke:var(--vscode-editor-foreground);
864867
stroke-opacity:0.5;
865868
stroke-width:0;
866869
}
867-
#findBtn svg, #terminalBtn svg{
870+
#currentBtn svg, #findBtn svg, #terminalBtn svg{
868871
stroke-width:0.5px;
869872
}
870-
#findBtn:hover svg, #terminalBtn:hover svg, #settingsBtn:hover svg, #fetchBtn:hover svg, #refreshBtn:hover svg{
873+
#currentBtn:hover svg, #findBtn:hover svg, #terminalBtn:hover svg, #settingsBtn:hover svg, #fetchBtn:hover svg, #refreshBtn:hover svg{
871874
opacity:1;
872875
stroke-width:0.5px;
873876
}
874-
#findBtn:hover svg, #terminalBtn:hover svg{
877+
#currentBtn:hover svg, #findBtn:hover svg, #terminalBtn:hover svg{
875878
stroke-width:1px;
876879
}
877-
#findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg{
880+
#currentBtn svg, #findBtn svg, #terminalBtn svg, #settingsBtn svg, #fetchBtn svg{
878881
left:1px;
879882
top:1px;
880883
width:18px !important;
@@ -897,6 +900,9 @@ body.tagLabelsRightAligned .gitRef.tag{
897900
#controls.fetchSupported{
898901
padding-right:162px;
899902
}
903+
#controls.fetchSupported #currentBtn{
904+
right:160px;
905+
}
900906
#controls.fetchSupported #findBtn{
901907
right:130px;
902908
}

web/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const SVG_ICONS = {
88
check: '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="16" viewBox="0 0 12 16"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"></path></svg>',
99
commit: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"/></svg>',
1010
copy: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/></svg>',
11+
current: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"> <path d="M 8.5793251,3.9709273 C 5.7393555,3.9722573 3.3857785,6.1732278 3.1943505,9.0067388 H 4.7680416 C 4.9548119,7.0413876 6.6051194,5.5401404 8.5793251,5.5397007 10.693557,5.5401531 12.407367,7.2539644 12.407817,9.3681961 12.408725,11.483388 10.694517,13.198699 8.5793251,13.199151 6.603404,13.198471 4.9524361,11.694493 4.7680416,9.727194 H 3.1943505 c 0.188959,2.835453 2.5432332,5.039225 5.3849746,5.04073 2.9812129,-0.0014 5.3972349,-2.418515 5.3972659,-5.3997279 -0.0014,-2.980253 -2.417013,-5.3958792 -5.3972659,-5.3972688 z m 0,3.1375466 c -0.8665744,3.13e-5 -1.655905,0.5013756 -2.0285866,1.2884596 0.4371757,0.1661687 0.9045642,0.3506253 1.2589529,0.4991552 0.3227657,0.135276 0.9442147,0.3573058 0.9442147,0.4745662 0,0.1172591 -0.621449,0.3368301 -0.9442147,0.4721071 -0.3543887,0.14853 -0.8217772,0.332987 -1.2589529,0.499155 0.3726816,0.787084 1.1620121,1.288429 2.0285866,1.28846 1.2398219,-0.0012 2.2444269,-1.012386 2.2449659,-2.2597221 8.1e-4,-1.2482965 -1.0041896,-2.2610032 -2.2449659,-2.262181 z M 5.579476,8.4313581 c -0.052649,0.00816 -0.07526,0.1152306 0,0.159828 L 6.4769718,9.1223068 H 2.3625859 L 1.8806431,8.3507087 H 0.01849445 l 0.752421,1.0199462 -0.752421,1.0199461 H 1.8806431 L 2.3650449,9.6165442 H 2.6825055 6.4794307 L 5.579476,10.150124 c -0.07526,0.0446 -0.052649,0.15167 0,0.159828 0.2360449,0.03657 1.406845,-0.369239 2.0900586,-0.614723 0.2586305,-0.092928 0.7573385,-0.244023 0.7573385,-0.3245741 0,-0.080552 -0.498708,-0.2316459 -0.7573385,-0.3245738 C 6.986321,8.8005973 5.815521,8.3947939 5.579476,8.4313581 Z" /></svg>',
1112
download: '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 -0.5 16 16.5"><path fill-rule="evenodd" d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"/></svg>',
1213
eyeOpen: '<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg>',
1314
eyeClosed: '<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 -1 16 16"><path fill-rule="evenodd" d="M14.822.854a.5.5 0 1 0-.707-.708l-2.11 2.11C10.89 1.483 9.565.926 8.06.926c-5.06 0-8.06 6-8.06 6s1.162 2.323 3.258 4.078l-2.064 2.065a.5.5 0 1 0 .707.707L14.822.854zM4.86 9.403L6.292 7.97A1.999 1.999 0 0 1 6 6.925c0-1.11.89-2 2-2 .384 0 .741.106 1.045.292l1.433-1.433A3.98 3.98 0 0 0 8 2.925c-2.2 0-4 1.8-4 4 0 .938.321 1.798.859 2.478zm7.005-3.514l1.993-1.992A14.873 14.873 0 0 1 16 6.925s-3 6-7.94 6a6.609 6.609 0 0 1-2.661-.57l1.565-1.566c.33.089.678.136 1.036.136 2.22 0 4-1.78 4-4 0-.358-.047-.705-.136-1.036zM9.338 8.415l.152-.151a1.996 1.996 0 0 1-.152.151z"/></svg>',

0 commit comments

Comments
 (0)