mattickx / copilotignore-vscode

Disable copilot extension when certain files are open listed in a .copilotignore file
MIT License
14 stars 4 forks source link

fix ipynb #6

Closed guzy0324 closed 5 months ago

guzy0324 commented 5 months ago

ipynb files have different uri format (https://github.com/microsoft/vscode/issues/97881#issue-618778392), which may be the reason why the vscode.workspace.asRelativePath(editor.document.uri) returns an absolute path instead of a relative path. Changing vscode.workspace.asRelativePath(editor.document.uri) to vscode.workspace.asRelativePath(editor.document.fsPath) simply fixes this bug.

guzy0324 commented 5 months ago

Related issue https://github.com/mattickx/copilotignore-vscode/issues/5.

mattickx commented 5 months ago

Looks good at first glance. Not able to publish right now. I'll take a look tomorrow and publish then. Thank you for your contribution @guzy0324

guzy0324 commented 5 months ago

I found that this fix causes another ipynb bug. Each cell in a notebook is an visibleTextEditor. And when switching from a notebook to other files, the cell is still in visibleTextEditors. As a result, the copilot will stay disabled unless the notebook is closed.

I fix the new bug by using visibleNotebookEditors for ipynb files, filtering out cells in visibleTextEditors.