Skip to content

Commit a681175

Browse files
committed
Replace Buffer instances with Uint8Array in file write and binary detection operations
- revert all those lint fixes [Changes] ├── .github │ └── workflows │ └── deploy-vscode-extension.yml ├── apps │ ├── browser │ │ └── package.json │ ├── editor │ │ ├── package.json │ │ ├── src │ │ │ ├── commands │ │ │ │ ├── apply-response-command │ │ │ │ │ ├── response-processor │ │ │ │ │ │ ├── handlers │ │ │ │ │ │ │ ├── diff-handler.ts │ │ │ │ │ │ │ ├── fast-replace-handler.ts │ │ │ │ │ │ │ ├── patch-repair-handler.ts │ │ │ │ │ │ │ ├── search-replace-handler.ts │ │ │ │ │ │ │ └── truncated-handler.ts │ │ │ │ │ │ └── response-processor.ts │ │ │ │ │ └── utils │ │ │ │ │ ├── file-operations │ │ │ │ │ │ ├── create-file-if-needed.ts │ │ │ │ │ │ ├── prepare-rename-operation.ts │ │ │ │ │ │ ├── read-rename-source-file.ts │ │ │ │ │ │ └── undo-files.ts │ │ │ │ │ └── preview │ │ │ │ │ ├── build-history-files.ts │ │ │ │ │ ├── file-preparer.ts │ │ │ │ │ ├── vscode-ui.ts │ │ │ │ │ └── workspace-listener.ts │ │ │ │ ├── copy-merge-commit-details-command.ts │ │ │ │ ├── new-folder-command.ts │ │ │ │ ├── search-files-commands │ │ │ │ │ └── utils │ │ │ │ │ └── get-target-folder-path.ts │ │ │ │ ├── select-files-of-commit-command.ts │ │ │ │ └── set-ranges-command.ts │ │ │ ├── context │ │ │ │ └── providers │ │ │ │ └── workspace │ │ │ │ └── modules │ │ │ │ └── token-calculator.ts │ │ │ ├── features │ │ │ │ └── search-files │ │ │ │ └── utils │ │ │ │ └── analyze-files.ts │ │ │ ├── services │ │ │ │ └── websocket-manager.ts │ │ │ ├── utils │ │ │ │ ├── agentic-cli-invocation │ │ │ │ │ ├── invoke-agentic-cli.ts │ │ │ │ │ └── utils │ │ │ │ │ └── check-command-exists.ts │ │ │ │ ├── files-collector.ts │ │ │ │ ├── git-repository-utils.ts │ │ │ │ ├── is-binary.ts │ │ │ │ ├── path-sanitizer.ts │ │ │ │ └── workspace-snapshot.ts │ │ │ └── views │ │ │ ├── prompt │ │ │ │ └── backend │ │ │ │ ├── message-handlers │ │ │ │ │ ├── handle-open-prompt-image.ts │ │ │ │ │ ├── handle-paste-url.ts │ │ │ │ │ ├── handle-patch-repair.ts │ │ │ │ │ ├── handle-preview-generated-code.ts │ │ │ │ │ ├── handle-save-prompt-image.ts │ │ │ │ │ ├── handle-voice-input.ts │ │ │ │ │ └── utils │ │ │ │ │ └── build-cli-prompt.ts │ │ │ │ └── utils │ │ │ │ ├── persistent-text-storage.ts │ │ │ │ ├── preview-text-in-temp-file.ts │ │ │ │ ├── symbols │ │ │ │ │ ├── fragment │ │ │ │ │ │ └── replace-fragment-symbol.ts │ │ │ │ │ ├── image │ │ │ │ │ │ └── replace-image-symbol.ts │ │ │ │ │ ├── pasted-text │ │ │ │ │ │ └── replace-pasted-text-symbol.ts │ │ │ │ │ └── website │ │ │ │ │ └── replace-website-symbol.ts │ │ │ │ └── website-fetcher.ts │ │ │ └── settings │ │ │ └── backend │ │ │ └── message-handlers │ │ │ ├── add-provider │ │ │ │ └── pick-extended-provider.ts │ │ │ ├── handle-open-allow-patterns-settings.ts │ │ │ └── handle-open-ignore-patterns-settings.ts │ │ ├── tsconfig.json │ │ └── webpack.config.ts │ └── web │ └── package.json ├── package.json ├── packages │ ├── shared │ │ └── package.json │ └── ui │ └── package.json └── pnpm-workspace.yaml
1 parent 328d688 commit a681175

18 files changed

Lines changed: 49 additions & 34 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Markdown prompts for chatbots, APIs, and CLIs with seamless integration",
5-
"version": "2026.1104.362",
5+
"version": "2026.1104.363",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

‎apps/editor/src/commands/apply-response-command/response-processor/handlers/diff-handler.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { Logger } from '@shared/utils/logger'
66
import { OriginalFileState } from '../../types/original-file-state'
77
import { create_safe_path } from '@/utils/path-sanitizer'
88
import { apply_diff } from '../../../../utils/changes-integration/diff-processor'
9-
import { remove_directory_if_empty, ensure_directory_exists } from '../../utils/file-operations'
9+
import {
10+
remove_directory_if_empty,
11+
ensure_directory_exists
12+
} from '../../utils/file-operations'
1013
import { DiffItem } from '../../utils/response-parser'
1114
import { get_error_message } from '@/utils/get-error-message'
1215

@@ -507,7 +510,7 @@ const process_diff = async (params: {
507510
try {
508511
await vscode.workspace.fs.writeFile(
509512
vscode.Uri.file(params.file_path),
510-
Buffer.from(result, 'utf8')
513+
new Uint8Array(Buffer.from(result, 'utf8'))
511514
)
512515
return result
513516
} catch (error) {

‎apps/editor/src/commands/apply-response-command/response-processor/handlers/fast-replace-handler.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ export const handle_fast_replace = async (params: {
144144
})
145145

146146
if (!is_pure_rename) {
147-
await vscode.workspace.fs.writeFile(
148-
vscode.Uri.file(safe_path),
149-
Buffer.from(file.content, 'utf8')
150-
)
147+
await vscode.workspace.fs.writeFile(
148+
vscode.Uri.file(safe_path),
149+
new Uint8Array(Buffer.from(file.content, 'utf8'))
150+
)
151151
}
152152

153153
original_states.push({
@@ -184,7 +184,10 @@ export const handle_fast_replace = async (params: {
184184
const file_uri = vscode.Uri.file(safe_path)
185185
const document = await vscode.workspace.openTextDocument(file_uri)
186186
const original_content_doc = document.getText()
187-
const final_content = preserve_trailing_newline(original_content_doc, file.content)
187+
const final_content = preserve_trailing_newline(
188+
original_content_doc,
189+
file.content
190+
)
188191

189192
original_states.push({
190193
file_path: file.file_path,

‎apps/editor/src/commands/apply-response-command/response-processor/handlers/patch-repair-handler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const handle_patch_repair = async (params: {
6161

6262
await vscode.workspace.fs.writeFile(
6363
vscode.Uri.file(safe_path),
64-
Buffer.from(patch_item.content, 'utf8')
64+
new Uint8Array(Buffer.from(patch_item.content, 'utf8'))
6565
)
6666
if (set_file_applied_with_patch_repair) {
6767
set_file_applied_with_patch_repair({

‎apps/editor/src/commands/apply-response-command/response-processor/handlers/search-replace-handler.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const handle_search_replace = async (params: {
127127
}
128128
await vscode.workspace.fs.writeFile(
129129
vscode.Uri.file(safe_path),
130-
Buffer.from(proposed_content, 'utf8')
130+
new Uint8Array(Buffer.from(proposed_content, 'utf8'))
131131
)
132132
}
133133

@@ -157,7 +157,7 @@ export const handle_search_replace = async (params: {
157157
if (current_content !== original_content) {
158158
await vscode.workspace.fs.writeFile(
159159
vscode.Uri.file(safe_path),
160-
Buffer.from(current_content, 'utf8')
160+
new Uint8Array(Buffer.from(current_content, 'utf8'))
161161
)
162162
}
163163

‎apps/editor/src/commands/apply-response-command/response-processor/handlers/truncated-handler.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const handle_truncated_edit = async (params: {
111111
proposed_content = process_truncations(file.content, original_content)
112112
await vscode.workspace.fs.writeFile(
113113
vscode.Uri.file(safe_path),
114-
Buffer.from(proposed_content, 'utf8')
114+
new Uint8Array(Buffer.from(proposed_content, 'utf8'))
115115
)
116116
}
117117

@@ -179,7 +179,7 @@ export const handle_truncated_edit = async (params: {
179179

180180
await vscode.workspace.fs.writeFile(
181181
vscode.Uri.file(safe_path),
182-
Buffer.from(new_content, 'utf8')
182+
new Uint8Array(Buffer.from(new_content, 'utf8'))
183183
)
184184

185185
original_states.push({

‎apps/editor/src/commands/apply-response-command/utils/file-operations/create-file-if-needed.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const create_file_if_needed = async (params: {
7979
try {
8080
await vscode.workspace.fs.writeFile(
8181
file_uri,
82-
Buffer.from(params.content, 'utf8')
82+
new Uint8Array(Buffer.from(params.content, 'utf8'))
8383
)
8484
Logger.info({
8585
function_name: 'create_file_if_needed',

‎apps/editor/src/commands/apply-response-command/utils/file-operations/undo-files.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const undo_files = async (params: {
128128
await ensure_directory_exists(safe_path)
129129
await vscode.workspace.fs.writeFile(
130130
file_uri,
131-
Buffer.from(state.content, 'utf8')
131+
new Uint8Array(Buffer.from(state.content, 'utf8'))
132132
)
133133

134134
Logger.info({
@@ -179,7 +179,7 @@ export const undo_files = async (params: {
179179
} else {
180180
await vscode.workspace.fs.writeFile(
181181
file_uri,
182-
Buffer.from(state.content, 'utf8')
182+
new Uint8Array(Buffer.from(state.content, 'utf8'))
183183
)
184184
}
185185
Logger.info({

‎apps/editor/src/commands/apply-response-command/utils/preview/workspace-listener.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ export const setup_workspace_listeners = (params: {
921921
try {
922922
await vscode.workspace.fs.writeFile(
923923
vscode.Uri.file(file_to_discard.sanitized_path),
924-
Buffer.from(proposed, 'utf8')
924+
new Uint8Array(Buffer.from(proposed, 'utf8'))
925925
)
926926
} finally {
927927
params.workspace_provider.resume_file_watcher()
@@ -1021,7 +1021,7 @@ export const setup_workspace_listeners = (params: {
10211021
} else {
10221022
await vscode.workspace.fs.writeFile(
10231023
vscode.Uri.file(file_to_toggle.sanitized_path),
1024-
Buffer.from(file_to_toggle.original_content, 'utf8')
1024+
new Uint8Array(Buffer.from(file_to_toggle.original_content, 'utf8'))
10251025
)
10261026
}
10271027
} else {
@@ -1040,10 +1040,12 @@ export const setup_workspace_listeners = (params: {
10401040
} else {
10411041
await vscode.workspace.fs.writeFile(
10421042
vscode.Uri.file(file_to_toggle.sanitized_path),
1043-
Buffer.from(
1044-
file_to_toggle.content_to_restore ??
1045-
file_to_toggle.previewable_file.content,
1046-
'utf8'
1043+
new Uint8Array(
1044+
Buffer.from(
1045+
file_to_toggle.content_to_restore ??
1046+
file_to_toggle.previewable_file.content,
1047+
'utf8'
1048+
)
10471049
)
10481050
)
10491051
}

‎apps/editor/src/commands/set-ranges-command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const set_ranges_command = (
4242
if (!is_binary) {
4343
try {
4444
const file_handle = await fs.open(file_path, 'r')
45-
const buffer = Buffer.alloc(8000)
45+
const buffer = new Uint8Array(8000)
4646
const { bytesRead } = await file_handle.read(buffer, 0, 8000, 0)
4747
await file_handle.close()
4848
is_binary = is_binary_file(file_path, buffer.subarray(0, bytesRead))

0 commit comments

Comments
 (0)