Home > Blockchain >  The way to fix unreal 4.27 vscode intelligence bug
The way to fix unreal 4.27 vscode intelligence bug

Time:11-30

The unreal engine 4.27 has bug on vscode intelligence.

I have find out how to fix it and write it out.

First the bug is the compileCommands_Default.json and compileCommands_LearnUE4.json is the main compilecommand file for vscode intelligence.

The bug is every "command" fields lost a double quotation marks. details show below

[
    {
        "file": "D:\\\\unreal\\\\LearnUE4\\\\Source\\\\LearnUE4\\\\LearnUE4.Build.cs",
        "command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe @\"D:\\unreal\\LearnUE4\\.vscode\\compileCommands_Default\\LearnUE4.210.rsp\"",
        "directory": "D:\\game\\UE_4.27\\Engine\\Source"
    }
]

Look at the command field

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe

which should change to "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe"

add a quotation at the begin and end.

CodePudding user response:

So I write a script to fix this.

import json
import re
from typing import List


def fix_cmd(filepath):
    with open(filepath) as fp:
        d = json.load(fp)
        for item in d:
            cmd = item['command']
            m: List[re.Match] = re.findall("(C:.*cl.exe) (@.*)", cmd)
            m0 = m[0]
            cmd = f"\"{m0[0]}\" {m0[1]}"
            item['command'] = cmd

    with open(filepath, 'w') as fp:
        json.dump(d, fp, indent='\t')


fix_cmd(".vscode/compileCommands_Default.json")
fix_cmd(".vscode/compileCommands_LearnUE4.json")

CodePudding user response:

My VSCode extension fixes this and other problems. https://github.com/boocs/ue4-intellisense-fixes

My solution was just to remove the path and just keep the cl.exe

I did report it to Epic a while ago, in a bug report, and gave them both solutions. But I think reporting is just a black hole that rarely works.

  • Related