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