Skip to content

Fix support for inmemory files in did_open#3137

Closed
austin3dickey wants to merge 1 commit intofacebook:mainfrom
austin3dickey:inmemory2
Closed

Fix support for inmemory files in did_open#3137
austin3dickey wants to merge 1 commit intofacebook:mainfrom
austin3dickey:inmemory2

Conversation

@austin3dickey
Copy link
Copy Markdown
Contributor

I didn't make an issue for this, but I can first if you'd like!

Summary

One-line change to fix inmemory documents (e.g. the Positron Console) failing to be registered with the server on Windows.

This is a follow-up to #1637, which added inmemory to the extension's documentSelector. That change works on Mac/Linux but not on Windows because the LSP server's did_open rejects inmemory URIs on that platform.

Root cause

When did_open receives an inmemory URI like inmemory:/repl-python-<uuid>, it calls Url::to_file_path(). That method doesn't check the URI scheme, it just converts path segments into a platform path. On Mac/Linux this happens to succeed (producing /repl-python-<uuid>), but on Windows it fails because file_url_segments_to_pathbuf_windows requires the first path segment to be a drive letter like C:.

After to_file_path() fails, the fallback in did_open only accepts untitled, so inmemory documents are silently rejected on Windows and never registered. But the fallback should work for both schemes.

Fix

Extend the scheme check in did_open to also accept inmemory, routing it through the UnsavedFileTracker. This makes the behavior consistent across platforms instead of relying on to_file_path() accidentally succeeding on Unix.

I added tests for semantic tokens and completions on inmemory documents, mirroring the existing untitled tests, so regressions here will be caught going forward.

Test Plan

  • Existing unsaved_file tests still pass
  • New tests pass
  • Verified completions and semantic highlighting work in Positron Console on Windows
  • Verified they still work in Positron Console on Mac
  • Ran test.py (no changes)

@github-actions
Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Contributor

@rchen152 rchen152 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 14, 2026

@rchen152 has imported this pull request. If you are a Meta employee, you can view this in D100894098.

Copy link
Copy Markdown
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 15, 2026

@rchen152 merged this pull request in b812c8a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants