Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic terminal command history #388

Merged
merged 2 commits into from Feb 24, 2014
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

minor cleanup on command history. removing unneeded var.

  • Loading branch information...
chriskoz committed Feb 24, 2014
commit b976461c290dfe43bf3bf83bb46d746b0ce09417
@@ -22,7 +22,6 @@ function TerminalViewModel(loginStateViewModel, settingsViewModel) {
self.filterRegex = undefined;

self.cmdHistory = [];
self.cmdHistoryCnt = 0;
self.cmdHistoryIdx = -1;

self.activeFilters = ko.observableArray([]);
@@ -109,8 +108,8 @@ function TerminalViewModel(loginStateViewModel, settingsViewModel) {
contentType: "application/json; charset=UTF-8",
data: JSON.stringify({"command": command})
});
self.cmdHistory[self.cmdHistoryCnt++] = command
self.cmdHistoryIdx = self.cmdHistoryCnt
self.cmdHistory.push(command);
self.cmdHistoryIdx = self.cmdHistory.length;
self.command("");
}
}
@@ -119,11 +118,11 @@ function TerminalViewModel(loginStateViewModel, settingsViewModel) {
if (event.keyCode == 13) {
self.sendCommand();
} else if (event.keyCode == 38) {
if (self.cmdHistoryIdx >= 0) {
if (self.cmdHistory.length >= 0 && self.cmdHistoryIdx >= 0) {
self.command(self.cmdHistory[--self.cmdHistoryIdx])
}
} else if (event.keyCode == 40) {
if (self.cmdHistoryIdx < self.cmdHistoryCnt) {
if (self.cmdHistoryIdx < self.cmdHistory.length) {
self.command(self.cmdHistory[++self.cmdHistoryIdx])
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.