Skip to content

this.doc is possibly undefined #218

@ssut

Description

@ssut

Please fill-in this template.

  • I have a question that is specific to this extension; thus, inappropriate for the main EditorConfig issue tracker.
  • I tried running code --disable-extensions and the issue did NOT present itself.

Delete the following condition if it doesn't apply to your case:

If the extension is not picking up the expected configuration for a file:

  • I tried npm install editorconfig -g and ran editorconfig [file-in-question] and the configuration was what I expected. If not, please file on the editorconfig-core-js issue tracker.

Issue

Visual Studio Code editorconfig-vscode
Version 1.30.2 0.12.7

Root .editorconfig File

does not exist but the problem is not related with the config file.

Are there any other relevant .editorconfig files in your project? Yes / No

Visual Studio Code Setting Default User Workspace
editor.insertSpaces true ____ ____
editor.tabSize 4 _ _
editor.trimAutoWhitespace true ____ ____
files.autoSave "off" "___" "___"
files.insertFinalNewline false _____ _____
files.trimTrailingWhitespace false _____ _____

File opened

./.../*.ts

Expected behavior

It outputs no error from the extension host.

Actual behavior

It throws an error saying that

 ERR Cannot read property 'fileName' of undefined: TypeError: Cannot read property 'fileName' of undefined
    at DocumentWatcher.<anonymous> (C:\Users\suhun\.vscode\extensions\editorconfig.editorconfig-0.12.7\out\src\DocumentWatcher.js:105:72)
    at Generator.next (<anonymous>)
    at __awaiter (C:\Users\suhun\.vscode\extensions\editorconfig.editorconfig-0.12.7\out\src\DocumentWatcher.js:6:71)
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\suhun\.vscode\extensions\editorconfig.editorconfig-0.12.7\out\src\DocumentWatcher.js:2:12)
    at DocumentWatcher.resolveConfig (C:\Users\suhun\.vscode\extensions\editorconfig.editorconfig-0.12.7\out\src\DocumentWatcher.js:98:16)
    at __dirname.constructor.subscriptions.push.vscode_1.window.onDidChangeWindowState.state (C:\Users\suhun\.vscode\extensions\editorconfig.editorconfig-0.12.7\out\src\DocumentWatcher.js:35:22)

Additional comments or steps to reproduce

I just focused on the editor.


I've found that DocumentWatcher.js#L52 can lead to this behavior if this.doc is not set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions