Skip to content

Commit 04c0686

Browse files
committed
Improve clipboard parsing to correctly handle PHP opening tags within code blocks
1 parent bd410a4 commit 04c0686

6 files changed

Lines changed: 35 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code Web Chat
22

3-
<a href="https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-VS_Code_Marketplace-blue" alt="Get from Visual Studio Code Marketplace" /></a> <a href="https://open-vsx.org/extension/robertpiosik/gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-Open_VSX_Registry-a60ee5" alt="Get from Open VSX Registry" /></a>
3+
<a href="https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-VS_Code_Marketplace-blue" alt="Get from Visual Studio Code Marketplace" /></a> <a href="https://open-vsx.org/extension/robertpiosik/gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-Open_VSX_Registry-a60ee5" alt="Get from Open VSX Registry" /></a> <a href="https://github.com/robertpiosik/CodeWebChat/blob/dev/LICENSE" target="_blank"><img src="https://img.shields.io/badge/License-GPL--3.0-green.svg" alt="License: GPL-3.0" /></a>
44

55
Code Web Chat is a versatile, free and open-source (FOSS) AI coding tool that connects VS Code with ChatGPT, AI Studio, DeepSeek, and 10+ other free chatbots.
66

@@ -13,11 +13,11 @@ Available in <a href="https://marketplace.visualstudio.com/items?itemName=robert
1313
<img src="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/demo.gif" alt="Walkthrough" />
1414
</p>
1515

16-
**How it works?**
16+
**The workflow**
1717

18-
CWC is dead simple—select folders and files you want to show to the model, type instructions, and pick your favorite chatbot, to continue in the browser, or call a model provider of choice, to stay in the editor.
18+
Select folders and files you want to show to the model, type instructions, and pick your favorite chatbot, to continue in the browser, or call a model provider of choice, to stay in the editor.
1919

20-
Once the response is ready, generated code blocks in the selected **EDIT FORMAT** can be applied with a single click.
20+
Once the response is ready, generated code blocks in the selected **EDIT FORMAT** can be applied with a single click!
2121

2222
| EDIT FORMAT | Token usage | File operations |
2323
| ----------- | :---------: | ---------------------- |
@@ -27,8 +27,6 @@ Once the response is ready, generated code blocks in the selected **EDIT FORMAT*
2727

2828
<small>\* Requires the Intelligent Update API tool to apply.</small>
2929

30-
> "Whole" and "truncated" edit formats are reliable with cheaper models, while "diff" is fast and may require a more capable one—like Gemini 2.5 Pro.
31-
3230
**Guiding principles**
3331

3432
- Initialize chatbots—don't scrape responses

‎packages/vscode/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": "CWC connects VS Code with ChatGPT, AI Studio, DeepSeek, and 10+ other free chatbots. Saves you money and time.",
5-
"version": "1.396.0",
5+
"version": "1.397.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/clipboard-parser.spec.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,20 @@ describe('clipboard-parser', () => {
305305
load_test_case_file('markdown-with-nested-code-block', 'file-1.txt')
306306
)
307307
})
308+
309+
it('should handle php opening tag before filename', () => {
310+
const text = load_test_case_file('php-opening-tag', 'php-opening-tag.txt')
311+
const result = parse_multiple_files({
312+
response: text,
313+
is_single_root_folder_workspace: true
314+
})
315+
316+
expect(result).toHaveLength(1)
317+
expect(result[0].file_path).toBe('src/index.php')
318+
expect(result[0].content).toBe(
319+
load_test_case_file('php-opening-tag', 'file-1.txt')
320+
)
321+
})
308322
})
309323

310324
describe('parse_file_content_only', () => {

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/clipboard-parser.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ export const parse_multiple_files = (params: {
359359
const trimmed_line = line.trim()
360360
let extracted_filename: string | null = null
361361

362+
if (trimmed_line.startsWith('<?php')) {
363+
if (current_content) {
364+
current_content += '\n' + line
365+
} else {
366+
current_content = line
367+
}
368+
continue
369+
}
370+
362371
const is_comment =
363372
trimmed_line.startsWith('//') ||
364373
trimmed_line.startsWith('#') ||
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo "Hello, World!";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```php
2+
<?php
3+
// src/index.php
4+
echo "Hello, World!";
5+
```

0 commit comments

Comments
 (0)