Skip to content

Fix error when opening file outside of any workspace #3815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { localPathToUri } from "./util/pathToUri";
import { Telemetry } from "./util/posthog";
import { getSymbolsForManyFiles } from "./util/treeSitter";
import { TTS } from "./util/tts";
import { findUriInDirs } from "./util/uri";

import {
ChatMessage,
Expand Down Expand Up @@ -892,10 +893,10 @@ export class Core {

on("didChangeActiveTextEditor", async ({ data: { filepath } }) => {
const ignoreInstance = ignore().add(defaultIgnoreFile);
let rootDirectory = await this.ide.getWorkspaceDirs();
const relativeFilePath = path.relative(rootDirectory[0], filepath);
const workspaceDirs = await this.ide.getWorkspaceDirs();
const { relativePathOrBasename } = findUriInDirs(filepath, workspaceDirs);
try {
if (!ignoreInstance.ignores(relativeFilePath)) {
if (!ignoreInstance.ignores(relativePathOrBasename)) {
recentlyEditedFilesCache.set(filepath, filepath);
}
} catch (e) {
Expand Down
Loading