Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/app/store/wshclientapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ class RpcApiType {
return client.wshRpcCall("dispose", data, opts);
}

// command "disposesuggestions" [call]
DisposeSuggestionsCommand(client: WshClient, data: string, opts?: RpcOpts): Promise<void> {
return client.wshRpcCall("disposesuggestions", data, opts);
}

// command "eventpublish" [call]
EventPublishCommand(client: WshClient, data: WaveEvent, opts?: RpcOpts): Promise<void> {
return client.wshRpcCall("eventpublish", data, opts);
Expand Down
7 changes: 5 additions & 2 deletions frontend/app/suggestion/suggestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SuggestionControlProps {
anchorRef: React.RefObject<HTMLElement>;
isOpen: boolean;
onClose: () => void;
onSelect: (item: SuggestionType, queryStr: string) => void;
onSelect: (item: SuggestionType, queryStr: string) => boolean;
onTab?: (item: SuggestionType, queryStr: string) => string;
fetchSuggestions: SuggestionsFnType;
className?: string;
Expand Down Expand Up @@ -256,8 +256,11 @@ const SuggestionControlInner: React.FC<SuggestionControlInnerProps> = ({
} else if (e.key === "Enter") {
e.preventDefault();
e.stopPropagation();
let suggestion: SuggestionType = null;
if (selectedIndex >= 0 && selectedIndex < suggestions.length) {
onSelect(suggestions[selectedIndex], query);
suggestion = suggestions[selectedIndex];
}
if (onSelect(suggestion, query)) {
onClose();
}
} else if (e.key === "Escape") {
Expand Down
4 changes: 4 additions & 0 deletions frontend/app/view/preview/directorypreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,10 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {

useEffect(() => {
const filtered = unfilteredData?.filter((fileInfo) => {
if (fileInfo.name == null) {
console.log("fileInfo.name is null", fileInfo);
return false;
}
if (!showHiddenFiles && fileInfo.name.startsWith(".") && fileInfo.name != "..") {
return false;
}
Expand Down
46 changes: 31 additions & 15 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1100,24 +1100,30 @@ const fetchSuggestions = async (
query: string,
reqContext: SuggestionRequestContext
): Promise<FetchSuggestionsResponse> => {
const conn = await globalStore.get(model.connection);
let route = makeConnRoute(conn);
if (isBlank(conn) || conn.startsWith("aws:")) {
route = null;
}
if (reqContext?.dispose) {
RpcApi.DisposeSuggestionsCommand(TabRpcClient, reqContext.widgetid, { noresponse: true, route: route });
return null;
}
const fileInfo = await globalStore.get(model.statFile);
if (fileInfo == null) {
return null;
}
const conn = await globalStore.get(model.connection);
return await RpcApi.FetchSuggestionsCommand(
TabRpcClient,
{
suggestiontype: "file",
"file:cwd": fileInfo.path,
query: query,
widgetid: reqContext.widgetid,
reqnum: reqContext.reqnum,
},
{
route: makeConnRoute(conn),
}
);
const sdata = {
suggestiontype: "file",
"file:cwd": fileInfo.path,
query: query,
widgetid: reqContext.widgetid,
reqnum: reqContext.reqnum,
"file:connection": conn,
};
return await RpcApi.FetchSuggestionsCommand(TabRpcClient, sdata, {
route: route,
});
};

function PreviewView({
Expand All @@ -1135,8 +1141,18 @@ function PreviewView({
if (connStatus?.status != "connected") {
return null;
}
const handleSelect = (s: SuggestionType) => {
const handleSelect = (s: SuggestionType, queryStr: string): boolean => {
console.log("handleSelect", s, queryStr);
if (s == null) {
if (isBlank(queryStr)) {
globalStore.set(model.openFileModal, false);
return true;
}
model.handleOpenFile(queryStr);
return true;
}
model.handleOpenFile(s["file:path"]);
return true;
};
const handleTab = (s: SuggestionType, query: string): string => {
if (s["mime:type"] == "directory") {
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/view/webview/webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,10 @@ const BookmarkTypeahead = memo(
onClose={() => model.setTypeaheadOpen(false)}
onSelect={(suggestion) => {
if (suggestion == null || suggestion.type != "url") {
return;
return true;
}
model.loadUrl(suggestion["url:url"], "bookmark-typeahead");
return true;
}}
fetchSuggestions={model.fetchBookmarkSuggestions}
placeholderText="Open Bookmark..."
Expand Down
Loading
Loading