lukas-tr / vscode-materialdesignicons-intellisense

Provides intellisense, search and hover preview for Material Design Icons
https://marketplace.visualstudio.com/items?itemName=lukas-tr.materialdesignicons-intellisense
MIT License
35 stars 7 forks source link

No preview icon #6

Closed nach00 closed 5 years ago

nach00 commented 5 years ago

Not sure what I did. I think I was messing around with my settings, but now the preview of the icon shows a broken image. The mdi folder still shows the icon, but when I type mdi-, the dropdown appears with all the names of the icons, but no preview. I've tried reinstalling with no success.

lukas-tr commented 5 years ago

If you messed with the extension files, you can try deleting the extension by hand.

  1. Uninstall the extension in vscode
  2. Go to the extension folder and delete lukas-tr.materialdesignicons-intellisense-1.5.2
    • Windows %USERPROFILE%\.vscode\extensions
    • Mac/Linux $HOME/.vscode/extensions
  3. Install the extension

You could also try opening your settings.json and commenting out all settings that start with materialdesigniconsIntellisense. and restarting vscode.


Since the icons in the MDI Explorer view are displaying correctly (assuming you meant that with "mdi folder"), there may be a bug in the markdown generation. You can verify that by adding following lines to util.js located in %USERPROFILE%\.vscode\extensions\lukas-tr.materialdesignicons-intellisense-1.5.2\out\ or $HOME/.vscode/extensions/lukas-tr.materialdesignicons-intellisense-1.5.2/out/

exports.encodeSpaces = (content) => {
    return content.replace(/ /g, "%20");
};
+ const chan = vscode.window.createOutputChannel("mdi")
exports.getIconData = (item) => {
    const svgPath = path.normalize(path.join(configuration_1.config.mdiPath, "svg", `${item.name}.svg`));
    return new Promise((resolve, reject) => {
        fs.readFile(svgPath, (err, data) => {
            if (err) {
                vscode.window.showErrorMessage(err.message);
                return reject(err);
            }
            const utf8String = data
                .toString("utf8")
                .replace(/<path/gi, `<path fill="${configuration_1.config.iconColor}" `);
            const previewSvg = "data:image/svg+xml;utf8;base64," +
                Buffer.from(utf8String).toString("base64") +
                exports.encodeSpaces(` | width=${configuration_1.config.iconSize} height=${configuration_1.config.iconSize}`);
+           chan.appendLine(previewSvg)
+           chan.appendLine(utf8String)
            return resolve({
                aliases: [item.name, ...item.aliases].join(", "),
                author: item.author,
                codepoint: item.codepoint,
                name: item.name,

After hovering over mdi-account, you should see following output (execute command View: Toggle Output and select mdi from the drop down list).

data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWFjY291bnQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYmFiYWJhIiAgZD0iTTEyLDRBNCw0IDAgMCwxIDE2LDhBNCw0IDAgMCwxIDEyLDEyQTQsNCAwIDAsMSA4LDhBNCw0IDAgMCwxIDEyLDRNMTIsMTRDMTYuNDIsMTQgMjAsMTUuNzkgMjAsMThWMjBINFYxOEM0LDE1Ljc5IDcuNTgsMTQgMTIsMTRaIiAvPjwvc3ZnPg==%20|%20width=100%20height=100
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="mdi-account" width="24" height="24" viewBox="0 0 24 24"><path fill="#bababa"  d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></svg>

If you want, you can try running the extension from source and adding the lines to src/util.ts instead of editing the extension directly (requires nodejs).

git clone https://github.com/lukas-tr/vscode-materialdesignicons-intellisense.git
cd vscode-materialdesignicons-intellisense
npm install
code .
# press f5 or go to the debug pane and click `start debugging`

This opens a new instance of vscode. If you tried this, does the preview display correctly there?


Could you post your settings.json if that didn't work? Are you using the stable or insiders build of vscode?

nach00 commented 5 years ago

Hmm.. I've tried all your suggestions. Still no bueno. I'm using Insiders.


    "vscode_custom_css.imports": [
        "file:///Users/Username/vscode-themes/synthwave84.css"
    ],
    "terminal.integrated.rendererType": "dom",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "editor.fontFamily": "FiraCode-Retina",
    "workbench.tree.indent": 32,
    "editor.tabSize": 2,
    "editor.fontLigatures": true,
    "editor.tabCompletion": "on",
    "editor.minimap.enabled": false,
    "workbench.sideBar.location": "right",
    "workbench.activityBar.visible": false,
    "workbench.colorTheme": "SynthWave '84",
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": false,
    "editor.quickSuggestions": {
        "strings": true,
    },
    "window.zoomLevel": 0,
    "insert-br-tag.enableOnLanguage": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "markdown",
        "html",
        "vue"
    ],
    "insert-br-tag.trailingSlashLanguage": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "vue"
    ],
    "explorer.confirmDragAndDrop": false,
    "discord.detailsIdle": "Compiling",
    "discord.largeImageIdle": "Compiling",
}
nach00 commented 5 years ago
  1. Uninstall the extension in vscode
  2. Go to the extension folder and delete lukas-tr.materialdesignicons-intellisense-1.5.2

    • Windows %USERPROFILE%\.vscode\extensions
    • Mac/Linux $HOME/.vscode/extensions
  3. Install the extension

You could also try opening your settings.json and commenting out all settings that start with materialdesigniconsIntellisense. and restarting vscode.

Tried this before I posted this issue. Weird, for some reason your lukas-tr.materialdesignicons-intellisense-1.5.2 folder is hidden.

+ const chan = vscode.window.createOutputChannel("mdi")
+           chan.appendLine(previewSvg)
+           chan.appendLine(utf8String)

After hovering over mdi-account, you should see following output (execute command View: Toggle Output and select mdi from the drop down list).

data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWFjY291bnQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYmFiYWJhIiAgZD0iTTEyLDRBNCw0IDAgMCwxIDE2LDhBNCw0IDAgMCwxIDEyLDEyQTQsNCAwIDAsMSA4LDhBNCw0IDAgMCwxIDEyLDRNMTIsMTRDMTYuNDIsMTQgMjAsMTUuNzkgMjAsMThWMjBINFYxOEM0LDE1Ljc5IDcuNTgsMTQgMTIsMTRaIiAvPjwvc3ZnPg==%20|%20width=100%20height=100
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="mdi-account" width="24" height="24" viewBox="0 0 24 24"><path fill="#bababa"  d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></svg>

Added these lines. I did not get the message above.

If you want, you can try running the extension from source and adding the lines to src/util.ts instead of editing the extension directly (requires nodejs).

git clone https://github.com/lukas-tr/vscode-materialdesignicons-intellisense.git
cd vscode-materialdesignicons-intellisense
npm install
code .
# press f5 or go to the debug pane and click `start debugging`

Gonna try this again. EDIT: Still no preview :(

lukas-tr commented 5 years ago
+ const chan = vscode.window.createOutputChannel("mdi")
+           chan.appendLine(previewSvg)
+           chan.appendLine(utf8String)

After hovering over mdi-account, you should see following output (execute command View: Toggle Output and select mdi from the drop down list).

data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWFjY291bnQiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYmFiYWJhIiAgZD0iTTEyLDRBNCw0IDAgMCwxIDE2LDhBNCw0IDAgMCwxIDEyLDEyQTQsNCAwIDAsMSA4LDhBNCw0IDAgMCwxIDEyLDRNMTIsMTRDMTYuNDIsMTQgMjAsMTUuNzkgMjAsMThWMjBINFYxOEM0LDE1Ljc5IDcuNTgsMTQgMTIsMTRaIiAvPjwvc3ZnPg==%20|%20width=100%20height=100
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="mdi-account" width="24" height="24" viewBox="0 0 24 24"><path fill="#bababa"  d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" /></svg>

Added these lines. I did not get the message above.

Strange. Did you get a different message or no message at all? Could you try to add a breakpoint before the return and then start debugging?

image

previewSvg and utf8String sould have following values:

"data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLW51bWVyaWMiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYmFiYWJhIiAgZD0iTTQsMTdWOUgyVjdINlYxN0g0TTIyLDE1QzIyLDE2LjExIDIxLjEsMTcgMjAsMTdIMTZWMTVIMjBWMTNIMThWMTFIMjBWOUgxNlY3SDIwQTIsMiAwIDAsMSAyMiw5VjEwLjVBMS41LDEuNSAwIDAsMSAyMC41LDEyQTEuNSwxLjUgMCAwLDEgMjIsMTMuNVYxNU0xNCwxNVYxN0g4VjEzQzgsMTEuODkgOC45LDExIDEwLDExSDEyVjlIOFY3SDEyQTIsMiAwIDAsMSAxNCw5VjExQzE0LDEyLjExIDEzLjEsMTMgMTIsMTNIMTBWMTVIMTRaIiAvPjwvc3ZnPg==%20|%20width=100%20height=100"
"<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="mdi-numeric" width="24" height="24" viewBox="0 0 24 24"><path fill="#bababa"  d="M4,17V9H2V7H6V17H4M22,15C22,16.11 21.1,17 20,17H16V15H20V13H18V11H20V9H16V7H20A2,2 0 0,1 22,9V10.5A1.5,1.5 0 0,1 20.5,12A1.5,1.5 0 0,1 22,13.5V15M14,15V17H8V13C8,11.89 8.9,11 10,11H12V9H8V7H12A2,2 0 0,1 14,9V11C14,12.11 13.1,13 12,13H10V15H14Z" /></svg>"
nach00 commented 5 years ago

I must be doing something wrong.

I've never used the debugging feature on VScode, so I'm a little lost. I have it set to the Launch Extension configuration, with these settings:

    {
      "type": "extensionHost",
      "request": "launch",
      "name": "Launch Extension",
      "runtimeExecutable": "${execPath}",
      "args": ["--extensionDevelopmentPath=${workspaceFolder}"],
      "outFiles": ["${workspaceFolder}/out/**/*.js"],
      "preLaunchTask": "npm"
    },

But it's throwing me an error, saying it could not find the task 'npm' even though I have it installed.

Thank you so much for the support for a beginner programmer like myself :)

image image image image

lukas-tr commented 5 years ago

If you want, you can try running the extension from source and adding the lines to src/util.ts instead of editing the extension directly (requires nodejs).

git clone https://github.com/lukas-tr/vscode-materialdesignicons-intellisense.git
cd vscode-materialdesignicons-intellisense
npm install
code .
# press f5 or go to the debug pane and click `start debugging`

This opens a new instance of vscode. If you tried this, does the preview display correctly there?

You likely tried debugging the built extension. This does not work - you need to clone this repository to a separate folder first.

The output of the above mentioned commands should look like this. image The folder node_modules should be there after executing npm install.

The launch config .vscode/launch.json should work without alteration. You only have to execute the Start Debugging (Default F5) command.

image

After the new instance opens, you can set a breakpoint (in the window with the title [...]vscode-materialdesignicons-instellisense - Visual St[...]) (command Debug: Toggle Breakpoint (Default: F9 with cursor in line 40) and reload the window (the green arrow at the top or Ctrl + Shift + F9).

After creating a new document, changing the language mode to eg html and typing mdi- (in the window with the title [Extension Development Host] - [...]), the line with the breakpoint will turn yellow.

nach00 commented 5 years ago

OK, I got it working now. Thanks for the step-by-step guide.

image

So what does this mean?

lukas-tr commented 5 years ago

Generating the data uri works as espected. It turns out that I was still on 1.37.0-insider and missed the update notification. I have the same problem after updating to 1.38.0. I created an issue here microsoft/vscode#79759.