Skip to content

Commit c0ee565

Browse files
committed
feat(file-highlight): add fileHighlightReadRange function to highlight read ranges in client editor
1 parent 90a358e commit c0ee565

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/client-pipe.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,24 @@ export async function fileReadContent(
810810
return result;
811811
}
812812

813+
/**
814+
* Open a file in the client editor and highlight the range that was just read.
815+
* Fire-and-forget — does not block the tool response.
816+
*/
817+
export function fileHighlightReadRange(
818+
filePath: string,
819+
startLine: number,
820+
endLine: number,
821+
): void {
822+
sendClientRequest(
823+
'file.highlightReadRange',
824+
{filePath, startLine, endLine},
825+
5_000,
826+
).catch(() => {
827+
// Best-effort — don't let highlight failures affect tool responses
828+
});
829+
}
830+
813831
/**
814832
* Apply a text replacement (range → new content) and save.
815833
*/

src/extension-watcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import path, {extname, join, relative} from 'node:path';
2626

2727
import {logger} from './logger.js';
2828

29-
const IGNORE_DIRS = new Set(['node_modules', 'dist', '.git']);
29+
const IGNORE_DIRS = new Set(['node_modules', 'dist', '.git', '.devtools']);
3030
const IGNORE_EXTENSIONS = new Set(['.vsix']);
3131
const DEVTOOLS_IGNORE_FILENAME = '.devtoolsignore';
3232
const EXT_FINGERPRINT_DIR = '.devtools';

src/tools/file/file-read.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import path from 'node:path';
88

9-
import {fileGetSymbols, fileReadContent} from '../../client-pipe.js';
9+
import {fileGetSymbols, fileReadContent, fileHighlightReadRange} from '../../client-pipe.js';
1010
import {getHostWorkspace} from '../../config.js';
1111
import {zod} from '../../third_party/index.js';
1212
import {ToolCategory} from '../categories.js';
@@ -108,6 +108,9 @@ export const read = defineTool({
108108

109109
const contentResult = await fileReadContent(filePath, readStartLine, readEndLine);
110110

111+
// Fire-and-forget: highlight the read range in the client editor
112+
fileHighlightReadRange(filePath, contentResult.startLine, contentResult.endLine);
113+
111114
// Truncate if necessary
112115
let content = contentResult.content;
113116
let truncated = false;

0 commit comments

Comments
 (0)