mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-30 09:44:26 +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;
|
||||
|
||||
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 = '';
|
||||
if(uc.length){
|
||||
for(const c of allCommandsSorted){
|
||||
if(c.indexOf(uc) === 0){
|
||||
shadowEl.innerHTML = c;
|
||||
if (lastCommand.length) {
|
||||
for (const c of allCommandsSorted) {
|
||||
if (c.startsWith(lastCommand)) {
|
||||
shadowEl.innerHTML = (currentValue + c.replace(lastCommand, '')).replace(/ /g, ' ');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +88,7 @@ var CommandPromptView = Backbone.View.extend({
|
|||
|
||||
if (e.keyCode === 9) {
|
||||
e.preventDefault();
|
||||
el.value = shadowEl.innerHTML;
|
||||
el.value = shadowEl.innerHTML.replace(/ /g, ' ');
|
||||
}
|
||||
|
||||
this.updatePrompt(el);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue