Skip to content

Commit d3d06c9

Browse files
committed
feat(apply_patch): set the correct filetype for diff
1 parent b89906e commit d3d06c9

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lua/opencode/ui/formatter.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ function M._format_apply_patch_tool(output, metadata, duration_text)
539539
for _, file in ipairs(metadata.files or {}) do
540540
M.format_action(output, icons.get('edit') .. ' apply patch', file.relativePath or file.filePath, duration_text)
541541
if config.ui.output.tools.show_output and file.diff then
542-
M.format_diff(output, file.diff, '')
542+
local file_type = file and util.get_markdown_filetype(file.filePath) or ''
543+
M.format_diff(output, file.diff, file_type)
543544
end
544545
end
545546
end

lua/opencode/util.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ function M.get_markdown_filetype(filename)
368368
local file_type_overrides = {
369369
javascriptreact = 'jsx',
370370
typescriptreact = 'tsx',
371+
typescript = 'ts',
372+
javascipt = 'js',
371373
sh = 'bash',
372374
yaml = 'yml',
373375
text = 'txt', -- nvim 0.12-nightly returns text as the type which breaks our unit tests

0 commit comments

Comments
 (0)