mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 23:51:16 -07:00
fix(cli): allow perfect match @-path completions to submit on Enter (#19562)
This commit is contained in:
@@ -4,7 +4,11 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { render as inkRenderDirect, type Instance as InkInstance } from 'ink';
|
||||
import {
|
||||
render as inkRenderDirect,
|
||||
type Instance as InkInstance,
|
||||
type RenderOptions,
|
||||
} from 'ink';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { Box } from 'ink';
|
||||
import type React from 'react';
|
||||
@@ -68,6 +72,25 @@ type TerminalState = {
|
||||
rows: number;
|
||||
};
|
||||
|
||||
type RenderMetrics = Parameters<NonNullable<RenderOptions['onRender']>>[0];
|
||||
|
||||
interface InkRenderMetrics extends RenderMetrics {
|
||||
output: string;
|
||||
staticOutput?: string;
|
||||
}
|
||||
|
||||
function isInkRenderMetrics(
|
||||
metrics: RenderMetrics,
|
||||
): metrics is InkRenderMetrics {
|
||||
const m = metrics as Record<string, unknown>;
|
||||
return (
|
||||
typeof m === 'object' &&
|
||||
m !== null &&
|
||||
'output' in m &&
|
||||
typeof m['output'] === 'string'
|
||||
);
|
||||
}
|
||||
|
||||
class XtermStdout extends EventEmitter {
|
||||
private state: TerminalState;
|
||||
private pendingWrites = 0;
|
||||
@@ -357,8 +380,10 @@ export const render = (
|
||||
debug: false,
|
||||
exitOnCtrlC: false,
|
||||
patchConsole: false,
|
||||
onRender: (metrics: { output: string; staticOutput?: string }) => {
|
||||
stdout.onRender(metrics.staticOutput ?? '', metrics.output);
|
||||
onRender: (metrics: RenderMetrics) => {
|
||||
if (isInkRenderMetrics(metrics)) {
|
||||
stdout.onRender(metrics.staticOutput ?? '', metrics.output);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user