mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 16:08:33 +00:00
Ruby test runs showed only console text: there was no Ruby output parser and test_*.rb was not a test file. A Minitest parser now builds the test tree (class, test, status, time, failure text) from verbose output (-v / TESTOPTS=-v), test_*.rb counts as a test file, jump to source finds the class and then its def, and the gutter gets a run action per test method (coloured by the last result) and per test class and module that holds test classes; one test, class or module runs with --name=.... The streaming Find in Files helper the jump to source uses moved from the search feature to src/platform, so the run feature doesn't import another feature. Co-authored-by: kjeldahl <[email protected]>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { Channel } from "@tauri-apps/api/core";
|
|
import {
|
|
call,
|
|
commands,
|
|
type FileMatches,
|
|
type RequestId,
|
|
type SearchEvent,
|
|
type SearchQuery,
|
|
type SearchSummary,
|
|
} from "@/platform/ipc";
|
|
|
|
/**
|
|
* Starts a streaming Find in Files request. `onFile` receives each file's
|
|
* matches as they are found; resolves with the summary (null when the
|
|
* request failed or was cancelled before it finished).
|
|
*/
|
|
export function streamSearch(
|
|
request: RequestId,
|
|
query: SearchQuery,
|
|
onFile: (f: FileMatches) => void,
|
|
): Promise<SearchSummary | null> {
|
|
return new Promise((resolve, reject) => {
|
|
let settled = false;
|
|
const finish = (s: SearchSummary | null) => {
|
|
if (settled) return;
|
|
settled = true;
|
|
resolve(s);
|
|
};
|
|
const channel = new Channel<SearchEvent>();
|
|
channel.onmessage = (ev) => {
|
|
if (settled) return;
|
|
if (ev.type === "file") onFile(ev.file);
|
|
else finish(ev.summary);
|
|
};
|
|
call(commands.searchStart(request, query, channel)).then(
|
|
// `done` normally arrives on the channel; don't hang if it never does.
|
|
() => setTimeout(() => finish(null), 2000),
|
|
(e) => {
|
|
if (settled) return;
|
|
settled = true;
|
|
reject(e);
|
|
},
|
|
);
|
|
});
|
|
}
|
|
|
|
export function cancelRequest(request: RequestId) {
|
|
void commands.cancelRequest(request).catch(() => {});
|
|
}
|