diff --git a/src/cpp/r/include/r/session/RConsoleHistory.hpp b/src/cpp/r/include/r/session/RConsoleHistory.hpp index 15543a8763d..6fce319c2c6 100644 --- a/src/cpp/r/include/r/session/RConsoleHistory.hpp +++ b/src/cpp/r/include/r/session/RConsoleHistory.hpp @@ -47,7 +47,7 @@ class ConsoleHistory : boost::noncopyable // COPYING: boost::noncopyable public: - void setCapacity(int capacity); + void setCapacity(long capacity); void setRemoveDuplicates(bool removeDuplicates); @@ -56,15 +56,15 @@ class ConsoleHistory : boost::noncopyable const_iterator begin() const { return historyBuffer_.begin(); } const_iterator end() const { return historyBuffer_.end(); } - int size() const + long size() const { return historyBuffer_.size(); } void clear(); - void subset(int beginIndex, // inclusive - int endIndex, // exclusive, + void subset(long beginIndex, // inclusive + long endIndex, // exclusive, std::vector* pEntries) const; void asJson(core::json::Array* pHistoryArray) const; diff --git a/src/cpp/r/session/RConsoleHistory.cpp b/src/cpp/r/session/RConsoleHistory.cpp index 72cb2251f6a..bf1e4e90a48 100644 --- a/src/cpp/r/session/RConsoleHistory.cpp +++ b/src/cpp/r/session/RConsoleHistory.cpp @@ -37,7 +37,7 @@ ConsoleHistory::ConsoleHistory() setCapacity(500); } -void ConsoleHistory::setCapacity(int capacity) +void ConsoleHistory::setCapacity(long capacity) { historyBuffer_.set_capacity(capacity); } @@ -85,8 +85,8 @@ void ConsoleHistory::clear() historyBuffer_.clear(); } -void ConsoleHistory::subset(int beginIndex, // inclusive - int endIndex, // exclusive, +void ConsoleHistory::subset(long beginIndex, // inclusive + long endIndex, // exclusive, std::vector* pEntries) const { // clear existing diff --git a/src/cpp/session/modules/SessionHistory.cpp b/src/cpp/session/modules/SessionHistory.cpp index 8bc9b49335c..1db665cf0fc 100644 --- a/src/cpp/session/modules/SessionHistory.cpp +++ b/src/cpp/session/modules/SessionHistory.cpp @@ -48,11 +48,11 @@ namespace { struct HistoryEntry { HistoryEntry() : index(0), timestamp(0) {} - HistoryEntry(int index, double timestamp, const std::string& command) + HistoryEntry(long index, double timestamp, const std::string& command) : index(index), timestamp(timestamp), command(command) { } - int index; + long index; double timestamp; std::string command; }; @@ -67,7 +67,7 @@ void historyEntriesAsJson(const std::vector& entries, json::Array indexArray, timestampArray, commandArray; for (std::size_t i=0; i historySize) || (endIndex < 0) || @@ -295,8 +295,8 @@ bool matches(const HistoryEntry& entry, } -void historyRangeAsJson(int startIndex, - int endIndex, +void historyRangeAsJson(long startIndex, + long endIndex, json::Object* pHistoryJson) { // get the subset of entries @@ -318,10 +318,11 @@ Error getRecentHistory(const json::JsonRpcRequest& request, json::JsonRpcResponse* pResponse) { // get params - int maxItems; - Error error = json::readParam(request.params, 0, &maxItems); + double maxItemsDbl; + Error error = json::readParam(request.params, 0, &maxItemsDbl); if (error) return error; + long maxItems = (long)maxItemsDbl; // alias console history using namespace r::session; @@ -332,8 +333,8 @@ Error getRecentHistory(const json::JsonRpcRequest& request, return Error(json::errc::ParamInvalid, ERROR_LOCATION); // compute start and end indexes - int startIndex = std::max(0, consoleHistory.size() - maxItems); - int endIndex = consoleHistory.size(); + long startIndex = std::max(0L, consoleHistory.size() - maxItems); + long endIndex = consoleHistory.size(); // get json and set it json::Object historyJson; @@ -346,15 +347,15 @@ Error getHistoryItems(const json::JsonRpcRequest& request, json::JsonRpcResponse* pResponse) { // get start and end index - int startIndex; // inclusive - int endIndex; // exclusive + double startIndex; // inclusive + double endIndex; // exclusive Error error = json::readParams(request.params, &startIndex, &endIndex); if (error) return error; // get the range and return it json::Object historyJson; - historyRangeAsJson(startIndex, endIndex, &historyJson); + historyRangeAsJson((long)startIndex, (long)endIndex, &historyJson); pResponse->setResult(historyJson); return Success(); } @@ -381,19 +382,19 @@ Error getHistoryArchiveItems(const json::JsonRpcRequest& request, json::JsonRpcResponse* pResponse) { // get start and end index - int startIndex; // inclusive - int endIndex; // exclusive + double startIndex; // inclusive + double endIndex; // exclusive Error error = json::readParams(request.params, &startIndex, &endIndex); if (error) return error; // truncate indexes if necessary - int historySize = historyArchive().size(); - startIndex = std::min(startIndex, historySize); - endIndex = std::min(endIndex, historySize); + long historySize = historyArchive().size(); + long startIndexLong = std::min((long)startIndex, historySize); + long endIndexLong = std::min((long)endIndex, historySize); // return json for the appropriate range - return setJsonResultFromHistory(startIndex, endIndex, pResponse); + return setJsonResultFromHistory(startIndexLong, endIndexLong, pResponse); } Error searchHistoryArchive(const json::JsonRpcRequest& request, @@ -401,10 +402,11 @@ Error searchHistoryArchive(const json::JsonRpcRequest& request, { // get the query std::string query; - int maxEntries; - Error error = json::readParams(request.params, &query, &maxEntries); + double maxEntriesDbl; + Error error = json::readParams(request.params, &query, &maxEntriesDbl); if (error) return error; + long maxEntries = maxEntriesDbl; // convert the query into a list of search terms std::vector searchTerms; @@ -444,10 +446,11 @@ Error searchHistoryArchiveByPrefix(const json::JsonRpcRequest& request, { // get the query std::string prefix; - int maxEntries; - Error error = json::readParams(request.params, &prefix, &maxEntries); + double maxEntriesDbl; + Error error = json::readParams(request.params, &prefix, &maxEntriesDbl); if (error) return error; + long maxEntries = (long)maxEntriesDbl; // trim the prefix boost::algorithm::trim(prefix); diff --git a/src/gwt/src/org/rstudio/studio/client/server/remote/RemoteServer.java b/src/gwt/src/org/rstudio/studio/client/server/remote/RemoteServer.java index 049620b16b7..32251827752 100644 --- a/src/gwt/src/org/rstudio/studio/client/server/remote/RemoteServer.java +++ b/src/gwt/src/org/rstudio/studio/client/server/remote/RemoteServer.java @@ -1020,7 +1020,7 @@ public void getHistoryItems( public void removeHistoryItems(JsArrayNumber itemIndexes, - ServerRequestCallback requestCallback) + ServerRequestCallback requestCallback) { sendRequest(RPC_SCOPE, REMOVE_HISTORY_ITEMS, diff --git a/src/gwt/src/org/rstudio/studio/client/workbench/views/history/History.java b/src/gwt/src/org/rstudio/studio/client/workbench/views/history/History.java index c577b48b696..f1958e1e2a1 100644 --- a/src/gwt/src/org/rstudio/studio/client/workbench/views/history/History.java +++ b/src/gwt/src/org/rstudio/studio/client/workbench/views/history/History.java @@ -12,6 +12,7 @@ */ package org.rstudio.studio.client.workbench.views.history; +import com.google.gwt.core.client.JsArrayNumber; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; @@ -358,7 +359,46 @@ void onHistorySendToSource() @Handler void onHistoryRemoveEntries() - { + { + // get selected indexes (bail if there is no selection) + final ArrayList selectedIndexes = view_.getSelectedCommandIndexes(); + if (selectedIndexes.size() < 1) + { + globalDisplay_.showErrorMessage( + "Error", + "No history entries currently selected."); + return; + } + + // bring view to front + view_.bringToFront(); + + globalDisplay_.showYesNoMessage( + GlobalDisplay.MSG_QUESTION, + "Confirm Remove Entries", + "Are you sure you want to remove the selected entries from " + + "the history?", + + new ProgressOperation() { + public void execute(final ProgressIndicator indicator) + { + indicator.onProgress("Removing items..."); + + JsArrayNumber indexes = (JsArrayNumber) + JsArrayNumber.createArray(); + + for (int i = 0; i requestCallback); + ServerRequestCallback requestCallback); /* diff --git a/src/gwt/src/org/rstudio/studio/client/workbench/views/history/view/HistoryPane.java b/src/gwt/src/org/rstudio/studio/client/workbench/views/history/view/HistoryPane.java index 5f237f0b1e4..3a6b2be14de 100644 --- a/src/gwt/src/org/rstudio/studio/client/workbench/views/history/view/HistoryPane.java +++ b/src/gwt/src/org/rstudio/studio/client/workbench/views/history/view/HistoryPane.java @@ -542,7 +542,7 @@ public void onBlur(BlurEvent event) return new Toolbar(new Widget[] { commands_.historySendToConsole().createToolbarButton(), commands_.historySendToSource().createToolbarButton(), - // commands_.historyRemoveEntries().createToolbarButton(), + // commands_.historyRemoveEntries().createToolbarButton(), commands_.clearHistory().createToolbarButton() }, new Widget[] { searchWidget_