mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 06:54:15 -07:00
Preserve tabs on paste (#12735)
This commit is contained in:
@@ -9,9 +9,15 @@ import type {
|
|||||||
ToolCallConfirmationDetails,
|
ToolCallConfirmationDetails,
|
||||||
ToolEditConfirmationDetails,
|
ToolEditConfirmationDetails,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
import { escapeAnsiCtrlCodes } from './textUtils.js';
|
import { escapeAnsiCtrlCodes, stripUnsafeCharacters } from './textUtils.js';
|
||||||
|
|
||||||
describe('textUtils', () => {
|
describe('textUtils', () => {
|
||||||
|
describe('stripUnsafeCharacters', () => {
|
||||||
|
it('should not strip tab characters', () => {
|
||||||
|
const input = 'hello world';
|
||||||
|
expect(stripUnsafeCharacters(input)).toBe('hello world');
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('escapeAnsiCtrlCodes', () => {
|
describe('escapeAnsiCtrlCodes', () => {
|
||||||
describe('escapeAnsiCtrlCodes string case study', () => {
|
describe('escapeAnsiCtrlCodes string case study', () => {
|
||||||
it('should replace ANSI escape codes with a visible representation', () => {
|
it('should replace ANSI escape codes with a visible representation', () => {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ export function cpSlice(str: string, start: number, end?: number): string {
|
|||||||
* - All printable Unicode including emojis
|
* - All printable Unicode including emojis
|
||||||
* - DEL (0x7F) - handled functionally by applyOperations, not a display issue
|
* - DEL (0x7F) - handled functionally by applyOperations, not a display issue
|
||||||
* - CR/LF (0x0D/0x0A) - needed for line breaks
|
* - CR/LF (0x0D/0x0A) - needed for line breaks
|
||||||
|
* - TAB (0x09) - preserve tabs
|
||||||
*/
|
*/
|
||||||
export function stripUnsafeCharacters(str: string): string {
|
export function stripUnsafeCharacters(str: string): string {
|
||||||
const strippedAnsi = stripAnsi(str);
|
const strippedAnsi = stripAnsi(str);
|
||||||
@@ -99,8 +100,8 @@ export function stripUnsafeCharacters(str: string): string {
|
|||||||
const code = char.codePointAt(0);
|
const code = char.codePointAt(0);
|
||||||
if (code === undefined) return false;
|
if (code === undefined) return false;
|
||||||
|
|
||||||
// Preserve CR/LF for line handling
|
// Preserve CR/LF/TAB for line handling
|
||||||
if (code === 0x0a || code === 0x0d) return true;
|
if (code === 0x0a || code === 0x0d || code === 0x09) return true;
|
||||||
|
|
||||||
// Remove C0 control chars (except CR/LF) that can break display
|
// Remove C0 control chars (except CR/LF) that can break display
|
||||||
// Examples: BELL(0x07) makes noise, BS(0x08) moves cursor, VT(0x0B), FF(0x0C)
|
// Examples: BELL(0x07) makes noise, BS(0x08) moves cursor, VT(0x0B), FF(0x0C)
|
||||||
|
|||||||
Reference in New Issue
Block a user