mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-01 10:14:28 +02:00
fix: right shadow and support multiple command
This commit is contained in:
parent
28c5df664a
commit
208d7e3038
1 changed files with 11 additions and 6 deletions
|
@ -70,12 +70,17 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
var el = e.target;
|
var el = e.target;
|
||||||
|
|
||||||
const shadowEl = document.querySelector('#shadow');
|
const shadowEl = document.querySelector('#shadow');
|
||||||
const uc = el.value.replace(/ {2,}/g, ' ');
|
|
||||||
|
const currentValue = el.value;
|
||||||
|
const allCommand = currentValue.split(';');
|
||||||
|
const lastCommand = allCommand[allCommand.length - 1]
|
||||||
|
.replace(/\s\s+/g, ' ').replace(/^\s/, '');
|
||||||
|
|
||||||
shadowEl.innerHTML = '';
|
shadowEl.innerHTML = '';
|
||||||
if(uc.length){
|
if (lastCommand.length) {
|
||||||
for(const c of allCommandsSorted){
|
for (const c of allCommandsSorted) {
|
||||||
if(c.indexOf(uc) === 0){
|
if (c.startsWith(lastCommand)) {
|
||||||
shadowEl.innerHTML = c;
|
shadowEl.innerHTML = (currentValue + c.replace(lastCommand, '')).replace(/ /g, ' ');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +88,7 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
|
|
||||||
if (e.keyCode === 9) {
|
if (e.keyCode === 9) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
el.value = shadowEl.innerHTML;
|
el.value = shadowEl.innerHTML.replace(/ /g, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updatePrompt(el);
|
this.updatePrompt(el);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue