Skip to content

[1.0.4] Preprocessor Fails Unless Included Files Have Explicit @line Source Mapping #79

Description

@MisterFoxi

The issue does not appear to be caused by include path resolution itself. The included files are correctly located through slVscodeEdit.preprocessor.includePaths.

However, the preprocessor appears to lose, or fail to initialize, the source mapping information for included files. As a result, the #include directive alone resolves the file, but preprocessing does not complete correctly unless a corresponding // @line directive is also present.

For example, this alone does not work correctly:

#include "DM_Common.lsl"

Adding the explicit source mapping makes preprocessing work:

#include "DM_Common.lsl"
// @line 1 "workspace:///Archivist/include/DM_Common.lsl"

The two directives serve different purposes:

  • #include tells the preprocessor which file to load and insert.
  • // @line provides the source URI and line-number mapping for the included file.

The observed behavior suggests a bug in the handling of source metadata for files included from a workspace subdirectory. Without the @line directive, the file is found, but its source context does not appear to be registered correctly. Adding the directive manually allows preprocessing to continue normally.

This therefore appears to be an issue with the automatic generation or propagation of @line metadata, rather than a problem with include path resolution.

Workspace structure

Archivist/
├── include/
│   ├── DM_Common.lsl
│   ├── DM_Release.lsl
│   ├── DM_StartupProtocol.lsl
│   └── DM_UpdateProtocol.lsl
├── lsl/
├── doc/
├── nc/
└── Archivist.code-workspace

Workspace configuration

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "slVscodeEdit.enabled": true,
        "slVscodeEdit.network.websocketPort": 9020,
        "slVscodeEdit.preprocessor.enable": true,
        "slVscodeEdit.preprocessor.includePaths": [
            ".",
            "./include/",
            "./lib",
            "**/include/"
        ],
        "slVscodeEdit.preprocessor.maxIncludeDepth": 10,
        "slVscodeEdit.preprocessor.lsl.switchStatements": true,
        "slVscodeEdit.sync.keepViewerFileOpen": true,
        "slVscodeEdit.sync.askIfViewerScriptMismatchesMaster": true,
        "slVscodeEdit.sync.includeFileMetaInOutput": true
    }
}

Expected behavior

The preprocessor should resolve and process the include correctly using only:

#include "DM_Common.lsl"

It should automatically generate or preserve the required @line source mapping metadata.

Actual behavior

The include file is found, but preprocessing only succeeds after manually adding:

// @line 1 "workspace:///Archivist/include/DM_Common.lsl"

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions