Compare commits

...

2 Commits

Author SHA1 Message Date
Evan Simkowitz e5a168f34c making textareainput functional component 2024-04-08 15:48:05 -07:00
Evan Simkowitz cc547e526b save 2024-04-08 14:20:10 -07:00
5 changed files with 406 additions and 384 deletions
@@ -0,0 +1,28 @@
// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import { SuggestionBlob } from "@/autocomplete/runtime/model";
import { GlobalModel } from "@/models";
import cn from "classnames";
import { useMemo } from "react";
export const AutocompleteSuggestions = async (props: { curLine: string }) => {
const inputModel = GlobalModel.inputModel;
const suggestions = await useMemo(async () => await inputModel.getSuggestions(), [props.curLine]);
if (!suggestions) {
return null;
}
const items = suggestions.suggestions.map((s) => `${s.icon} ${s.name}`);
return (
<div className="autocomplete-suggestions">
{items.map((item, idx) => (
<div key={idx} className={cn("autocomplete-item")}>
{item}
</div>
))}
</div>
);
};
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -9,8 +9,6 @@ export type ExecuteShellCommandTTYResult = {
code: number | null;
};
const pathSep = getApi().pathSep();
export const buildExecuteShellCommand =
(timeout: number): Fig.ExecuteCommandFunction =>
async ({ command, env, args, cwd }: Fig.ExecuteCommandInput): Promise<Fig.ExecuteCommandOutput> => {
@@ -35,6 +33,6 @@ export const resolveCwd = async (
): Promise<{ cwd: string; pathy: boolean; complete: boolean }> => {
if (cmdToken == null) return { cwd, pathy: false, complete: false };
const { token } = cmdToken;
const sep = shell == Shell.Bash ? "/" : pathSep;
const sep = shell == Shell.Bash ? "/" : getApi()?.pathSep();
return { cwd: cwd, pathy: true, complete: token.endsWith(sep) };
};
+10 -1
View File
@@ -7,8 +7,11 @@ import { boundMethod } from "autobind-decorator";
import { isBlank } from "@/util/util";
import * as appconst from "@/app/appconst";
import { Model } from "./model";
import { GlobalCommandRunner } from "./global";
import { GlobalCommandRunner, GlobalModel } from "./global";
import { app } from "electron";
import { SuggestionBlob } from "@/autocomplete/runtime/model";
import { useMemo } from "react";
import { Shell, getSuggestions } from "@/autocomplete";
function getDefaultHistoryQueryOpts(): HistoryQueryOpts {
return {
@@ -801,6 +804,12 @@ class InputModel {
})();
}
getSuggestions(): Promise<SuggestionBlob> {
const festate = GlobalModel.getCurRemoteInstance().festate;
return getSuggestions(this.getCurLine(), festate.cwd, festate.shelltype as Shell);
}
getCurLine(): string {
const hidx = this.historyIndex.get();
if (hidx < this.modHistory.length && this.modHistory[hidx] != null) {