Added tip about clearing auto-suggestion for commands, and reversed the suggested list.

This commit is contained in:
abdulmohsen
2024-07-09 20:55:08 +03:00
parent ec8c1c1a65
commit 5f8b85bf8f

View File

@@ -96,11 +96,13 @@
There is an environment variable <code>WS_CONSOLE_ENABLE_ALL</code> that can be set to <code>true</code>
to enable all commands to be run from the console. This is disabled by default.
</li>
<li>To clear the recent commands auto-suggestions, you can use the <code>clear_ac</code> command.</li>
</ul>
</Message>
</div>
<datalist id="recent_commands">
<option v-for="item in executedCommands" :key="item" :value="item"/>
<option v-for="item in recentCommands" :key="item" :value="item"/>
</datalist>
</div>
</template>
@@ -213,8 +215,14 @@ const finished = async () => {
await useRouter().push({path: '/console'})
}
if (!executedCommands.value.includes(command.value)) {
executedCommands.value.push(command.value)
if (executedCommands.value.includes(command.value)) {
executedCommands.value.splice(executedCommands.value.indexOf(command.value), 1)
}
executedCommands.value.push(command.value)
if (executedCommands.value.length > 30) {
executedCommands.value.shift()
}
command.value = ''
@@ -223,6 +231,8 @@ const finished = async () => {
command_input.value.focus()
}
const recentCommands = computed(() => executedCommands.value.reverse().slice(-10))
const reSizeTerminal = () => {
if (!terminal.value) {
return