Skip to content

add support for unsaved buffers#12

Open
BehrRiley wants to merge 3 commits into
DenizenScript:masterfrom
BehrRiley:feature/unsaved-buffers
Open

add support for unsaved buffers#12
BehrRiley wants to merge 3 commits into
DenizenScript:masterfrom
BehrRiley:feature/unsaved-buffers

Conversation

@BehrRiley

Copy link
Copy Markdown

This pull request adds support for syntax highlighting/linting/autocomplete features in unsaved (untitled) files in VSCode; relevant discord conversation

Currently, the extension explicitly filtered for physical .dsc files both on the client and server side; users can't use the extension in quick notepads without saving them to disk first.

Frontend/TypeScript changes

  • updated the documentSelector for the client to explicitly include the missing/blank { scheme: 'untitled', language: 'denizenscript' }
  • refactored various string-matching checks (like .endsWith(".dsc")) in extension.ts to instead rely on VSCode's built-in document.languageId === 'denizenscript'; this fixes the client's language auto detecting
  • reorganized configuration parsing

Backend/C# Changes

I'm not very experienced with C#, but i made sure to consistently reference docs and guides;

  • added a static WorkspaceTracker.IsDenizenDocument(Uri uri) helper replacing repeated doc validation across the server
  • updated TextDocumentService and DiagnosticProvider to properly process docs with the untitled scheme that was missing
  • added an UntitledPayloads dictionary to WorkspaceTracker; since untitled files don't exist on disk, their text payload is now cached here when updated so the ScriptChecker can successfully read and lint them

Testing

  • verified working by opening the extension in the extension development host:
    verified working example

Some side notes;
i changed the return types for getColorData, fixDark, and getTagColor because they returned strings; they actually returned null in a few cases and made the compilation console angry so i made it return string | null instead

BehrRiley added 2 commits July 1, 2026 02:36
- add `{ scheme: 'untitled' }` to the LSP document selector
- update `WorkspaceTracker` to store and provide payloads for untitled files so `ScriptChecker` can lint them
- refactor extension string checks
- add an `IsDenizenDocument` helper
Comment thread extension/src/extension.ts Outdated
if (inTagCounter == 0) {
const tagText : string = arg.substring(tagStart + 1, i);
let autoColor : string = getTagColor(tagText, textColor);
const autoColor = getTagColor(tagText, textColor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

bunch of stray edits in this file

Comment thread extension/package-lock.json Outdated
{
"name": "denizenscript",
"version": "1.4.8",
"version": "1.4.9",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should not be touched by a PR

Comment thread DenizenLangServer/WorkspaceTracker.cs Outdated
{
return;
}
if (file.Scheme == "untitled" && content != null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is not null

Comment thread DenizenLangServer/WorkspaceTracker.cs
- revert `package-lock.json`
- fix `UntitledPayloads` memory leak
- update `WorkspaceTracker.cs`
- reverted unrelated ts edits in `extension.ts` to keep the pull request strictly focused on the unsaved buffers feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants