Skip to content

Commit 3cc37a3

Browse files
committed
feat(context): improve inline selection formatting
Update the inline visual selection text to use bolded file path formatting (**`path/to/file`**) instead of the previous "Here is some code from" prefix. Adjust unit tests to match the new output format. This change makes the inserted context more visually distinct and concise.
1 parent 8f6725c commit 3cc37a3

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lua/opencode/context.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ end
168168
--- Captures the current visual selection and returns the text to be inserted inline
169169
--- into the opencode input buffer, in the form:
170170
---
171-
--- Here is some code from <file-path>:
171+
--- **`path/to/file`**
172172
---
173173
--- ```<filetype>
174174
--- <selected text>
@@ -198,7 +198,7 @@ function M.build_inline_selection_text(range)
198198

199199
local filetype = vim.bo[buf].filetype or ''
200200
local text = string.format(
201-
'Here is some code from %s:\n\n```%s\n%s\n```',
201+
'**`%s`**\n\n```%s\n%s\n```',
202202
file.path,
203203
filetype,
204204
current_selection.text

tests/unit/context_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ describe('build_inline_selection_text', function()
11821182
local text = context.build_inline_selection_text()
11831183

11841184
assert.is_not_nil(text)
1185-
assert.is_not_nil(text:match('Here is some code from /tmp/test%.lua:'))
1185+
assert.is_not_nil(text:match('%*%*`/tmp/test%.lua`%*%*'))
11861186
assert.is_not_nil(text:match('```lua'))
11871187
assert.is_not_nil(text:match('function foo%(%)'))
11881188
assert.is_not_nil(text:match('```$'))

0 commit comments

Comments
 (0)