Skip to content

VSCode Extension: Complete but needs debugging #1

@genro

Description

@genro

Overview

VSCode extension for gtext has been fully implemented but needs debugging before release.

What Works ✅

gtext serve command

  • Fully functional HTTP server with live preview
  • Auto-refresh on file changes
  • Correct processing of all include blocks:
    • File includes
    • CLI command execution
    • Live reload

Test confirmed:

cd temp
gtext serve test.md.gtext --port 8091
curl http://localhost:8091  # Shows fully processed content

All include blocks are processed correctly:

  • includes/header.md → included
  • includes/features.md → included
  • cli: date → executed and output included
  • cli: ls -la includes/ → executed and output included
  • cli: python3 -c "..." → executed and output included
  • includes/footer.md → included

What Doesn't Work ❌

VSCode Extension

The extension structure is complete but something isn't working:

Problem: When opening the preview in VSCode Extension Development Host, "non cambia nulla" (nothing shows/changes)

Symptoms:

  • File opens in Extension Development Host
  • Preview command available
  • But no visible changes or syntax highlighting observed

File Structure Created

Extension Files (/Users/gporcari/Sviluppo/genro_ng/vscode-gtext/)

vscode-gtext/
├── package.json                    # Extension manifest
├── tsconfig.json                   # TypeScript config
├── src/
│   ├── extension.ts               # Main extension logic
│   └── diagnostics.ts             # Real-time error detection
├── syntaxes/
│   └── gtext.tmLanguage.json      # Syntax highlighting
├── snippets/
│   └── gtext.json                 # Code snippets
├── images/
│   ├── icon.png                   # Extension icon (weaverbird, transparent)
│   └── gtext-file.png             # File type icon
└── language-configuration.json    # Language config

Test Files (/Users/gporcari/Sviluppo/genro_ng/gtext/temp/)

temp/
├── test.md.gtext                  # Main test file with include blocks
└── includes/
    ├── header.md                  # Header content
    ├── features.md                # Features list
    └── footer.md                  # Footer content

Extension Features Implemented

  1. Commands:

    • gtext.preview - Open preview in current column
    • gtext.previewToSide - Open preview to the side
    • gtext.stopServer - Stop preview server
  2. Language Support:

    • File extension: .gtext
    • Syntax highlighting for include blocks
    • File icon
  3. Snippets:

    • inc / include - Include file block
    • inccli / cli - Include CLI command block
    • incglob / glob - Include glob pattern block
  4. Diagnostics:

    • Error: Unclosed include blocks
    • Warning: Include block not on its own line
    • Warning: Backslashes in file paths
  5. Configuration:

    • gtext.preview.port (default: 8090)
    • gtext.preview.autoRefresh (default: true)
  6. Server Integration:

    • Spawns gtext serve as child process
    • Monitors stderr for errors
    • Shows webview with iframe to localhost:port
    • Auto-cleanup on extension deactivation

Testing Steps

  1. Open VSCode in /Users/gporcari/Sviluppo/genro_ng/vscode-gtext/
  2. Press F5 to launch Extension Development Host
  3. In new window, open /Users/gporcari/Sviluppo/genro_ng/gtext/temp/test.md.gtext
  4. Click preview icon in editor title bar (or use command palette)
  5. Expected: Should see processed content with all includes resolved
  6. Actual: "non cambia nulla" (nothing visible/no change)

Possible Issues to Investigate

  1. TypeScript compilation: Check if out/extension.js was generated
  2. Extension activation: Check if extension activates on .gtext files
  3. Webview rendering: Check if webview panel is created
  4. Server spawning: Check if gtext serve starts correctly
  5. Port conflicts: Check if port 8090 is available
  6. Error messages: Check Debug Console in VSCode for errors

Debug Steps

# Check TypeScript compilation
cd /Users/gporcari/Sviluppo/genro_ng/vscode-gtext
npm run compile
ls -la out/

# Verify gtext serve works standalone
cd /Users/gporcari/Sviluppo/genro_ng/gtext/temp
gtext serve test.md.gtext --port 8090

# In another terminal, test the server
curl http://localhost:8090 | head -50

Configuration Files

package.json key sections

  • Port default: 8090
  • Activation: onLanguage:gtext
  • Main: ./out/extension.js
  • Commands registered with icons

extension.ts (src/extension.ts:144-200)

Server spawning logic with error handling for:

  • Command not found
  • Port already in use
  • Server startup detection

Next Steps

  1. Debug why extension doesn't show changes in Extension Development Host
  2. Check VSCode Output and Debug Console for errors
  3. Verify TypeScript compilation succeeded
  4. Test if language features (syntax highlighting, snippets) work
  5. Test if preview command appears and executes
  6. Once working, package extension: vsce package
  7. Publish to VSCode Marketplace or use locally

Additional Notes

  • Icon created from official gtext logo (weaverbird only, transparent background)
  • All file paths use forward slashes (cross-platform)
  • Server uses polling-based auto-refresh (1 second interval)
  • Extension properly cleans up server process on deactivation

Related Files

  • gtext server: gtext/gtext/server.py
  • gtext CLI: gtext/gtext/cli.py
  • Test file: gtext/temp/test.md.gtext
  • Extension: vscode-gtext/src/extension.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions