ttax00 / code-yew-server

An extension that provides some language features for Yew's html macro syntax in Rust
GNU General Public License v3.0
55 stars 4 forks source link

FIX incomplete or `undefined` document symbol #2

Closed ttax00 closed 2 years ago

ttax00 commented 2 years ago

When executing document symbol command with virtual document:


      <header class="fixed z-10 w-screen bg-gray-500 dark:bg-gray-800">
    <nav class="mx-auto px-2 sm:px-6 lg:px-8 grid grid-cols-2 md:grid-cols-3 gap-2">
        <div class="relative flex items-center justify-start h-16 col-span-1 md:col-span-2">
            <a href="#introduction" class="text-black dark:text-white">             </a>
            <div class="form-check form-switch ml-4">

            </div>
            <img src="./asset/moon-svgrepo-com.svg" alt="Night mode"
            class="h-8 w-8 filter dark:invert ml-4" />
        </div>
        <ul class="relative hidden sm:flex items-center justify-end h-16 text-black dark:text-white">
            <li class="mr-3">              </li>
            <li>
                <a href="https://www.rust-lang.org/">
                    <img src="https://upload.wikimedia.org/wikipedia/commons/d/d5/Rust_programming_language_black_logo.svg"
                    class="h-10 w-10 mr-3 filter dark:invert" alt="Rust" />
                </a>
            </li>
            <li>
                <a href="https://yew.rs/" >
                    <img src="https://yew.rs/img/logo.png"
                    class="h-10 w-10 mr-3" alt="Yew" />
                </a>
            </li>
            <li>
                <a href="https://tailwindcss.com/">
                    <img src="https://upload.wikimedia.org/wikipedia/commons/d/d5/Tailwind_CSS_Logo.svg"
                    class="h-10 w-10" alt="Tailwind CSS" />
                </a>
            </li>
        </ul>
    </nav>
</header>

There was only 3 symbols detected and returned. image

Expecting: image Which should be the same as making a new .html file with the content.

On first initialize, the symbols returned would be undefined instead of Symbol[].

Concerned snippet of code:

async provideDocumentSymbols(document, token, next) {
console.log("doing symbol!");
let result = undefined;
// FIXME: [1] result is undefined for a long time, perhaps HTML Language Service isn't started yet?
// FIXME: [2] HTML document symbol provided are greatly missing!
result = await commands.executeCommand<DocumentSymbol[]>(
    'vscode.executeDocumentSymbolProvider',
    vdocUri(document),
);

console.debug(result);
return result;
},