Skip to content

Better handling of unknown file types - late reject #1533

@rakotomandimby

Description

@rakotomandimby

Hi all,

I am working on a Node project involving .ts and .ejs files.
When using the chat pane and provinding .ts files, everything is OK.
Example:

#file:src/foo/index.ts
#file:src/bar/blabla.ts

I want you to ...

But if I do the same thing but with the .ejs files:

# User  ───

#file:code/views/about.ejs

Tell me what does this file do?

# Copilot  ───

error
File not found: code/views/about.ejs

It seems to be because of this piece of code in lua/CopilotChat/utils/files.lua:

local function filter_files(files, max_count)
  local filetype = require('plenary.filetype')

  files = vim.tbl_filter(function(file)
    if file == nil or file == '' then
      return false
    end

    local ft = filetype.detect(file, {
      fs_access = false,
    })

    if ft == '' or not ft then
      return false
    end

    return true
  end, files)
  ...
end

I understand the possible reasons of rejecting non detected file types.
But what about

  • adding a (layer of) check that it is actuelly a text file, and if it is a text file, return "text" as file type
  • if it is not detected as a text file, then return false

This would solve the problem of people using EJS, PlantUML, and any other not well known file types, but reject binary ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions