Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphQL] Add support for Block Strings #261

Merged
merged 5 commits into from Mar 25, 2021

Conversation

jeremywiebe
Copy link
Contributor

@jeremywiebe jeremywiebe commented Mar 5, 2021

This PR extends the GraphQL file support to include Block Strings.

This is not complete. I have preliminary support working, but indentation is broken. Will see if I can get that working.

Closes: #260

@stkb
Copy link
Owner

stkb commented Mar 20, 2021

Hi, I've rebased and added a test for where a block string is used within code. Is there anything that's still not working?

@jeremywiebe
Copy link
Contributor Author

Hi @stkb! Thanks for pushing that commit. This is really close. I noticed that for indented block strings, Rewrap loses the indentation... eg.

Before:

type Mutation {
    """
    This is a long line. If Rewrap wraps it, it will pull this line to the left margin.
    """
    loginUserWithPassword(username: String!, password: String!) String
}

After

type Mutation {
    """
This is a long line. If Rewrap wraps it, it will pull 
this line to the left margin 
    """
    loginUserWithPassword(username: String!, password: String!) String
}

I'll see if I can fix up the regex later today as that's where I feel the issue might lie. :)

@stkb
Copy link
Owner

stkb commented Mar 22, 2021

Not sure why it's not working for you. It's working fine for me! (also in the CI)

If you like you can test it by installing the extension from this file (rename the .zip file to .vsix and install from within vscode)
rewrap-1.14.1-alpha.1.zip

If you're happy I'll go ahead and merge it.

@jeremywiebe
Copy link
Contributor Author

jeremywiebe commented Mar 22, 2021 via email

@stkb
Copy link
Owner

stkb commented Mar 23, 2021

Hmm yeah I see. I'm not getting the same though. Have you tried with all other extensions disabled?

@jeremywiebe
Copy link
Contributor Author

Hm... I disabled every extension and uninstalled Rewrap. Even then, if I run the code, it still strips the leading indent like in the video. Does Rewrap do any logging that'd help figure out what's going on? Sorry, I'm very unfamiliar with F# and it's taking me a bit to trace how it works. :)

@stkb
Copy link
Owner

stkb commented Mar 23, 2021

Yeah I wouldn't go spending time trying to figure out the F# codebase just yet because it's not easy. It doesn't really have any logging, but I could add some or direct you where to look while debugging.

In the mean time could you paste your settings.json here? (Remove anything personal) Also it may sound silly but could you attach a copy of an example file that's not working for you? (you may have to zip it up)

Do you have Visual Studio installed or just VS Code?

I will get back to you tomorrow (European time)

@jeremywiebe
Copy link
Contributor Author

Here's settings.json

Expand

{
    "[go]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        }
    },
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[jsonc]": {
        "editor.formatOnSave": false,
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "[markdown]": {
        "editor.formatOnSave": false
    },
    "[python]": {
        "editor.formatOnSave": false
    },
    "[shellscript]": {
        "editor.formatOnSave": false,
    },
    "[xml]": {
        "editor.formatOnSave": false
    },
    "[yaml]": {
        "editor.formatOnSave": false
    },

    "debug.console.fontFamily": "Hasklig",
    "debug.console.fontSize": 13,

    "diffEditor.renderSideBySide": false,

    "editor.autoClosingBrackets": "never",
    "editor.dragAndDrop": false,
    "editor.fontLigatures": true,
    "editor.fontFamily": "Hasklig",
    "editor.fontSize": 13,
    "editor.formatOnSave": true,
    "editor.insertSpaces": true,
    "editor.minimap.enabled": false,
    "editor.renderWhitespace": "none",
    "editor.rulers": [
        79
    ],
    "editor.scrollBeyondLastLine": false,
    "editor.suggest.localityBonus": true,
    "editor.tabCompletion": "on",

    "explorer.openEditors.visible": 0,

    "extensions.ignoreRecommendations": false,

    "files.associations": {"*.gotxt": "go"},
    "files.autoGuessEncoding": true,
    "files.insertFinalNewline": true,
    "files.trimTrailingWhitespace": true,

    "flow.showUncovered": true,

    "git.ignoreMissingGitWarning": true,

    "gitlens.codeLens.enabled": false,

    "go.autocompleteUnimportedPackages": true,
    "go.lintTool": "golangci-lint",
    "go.lintFlags": [
        "--fast",
        "--fix"
    ],
    "javascript.autoClosingTags": false,
    "javascript.suggest.autoImports": false,
    "javascript.updateImportsOnFileMove.enabled": "never",

    "npm.packageManager": "yarn",

    "prettier.requireConfig": true,

    "python.formatting.provider": "black",
    "python.formatting.blackPath": "/usr/local/bin/black",
    "python.formatting.blackArgs": [
        "--skip-string-normalization",
        "--line-length", "79"
    ],
    "python.languageServer": "Pylance",

    "rewrap.reformat": true,
    "rewrap.wrappingColumn": 79,
    "rewrap.wholeComment": false,
    "rewrap.autoWrap.enabled": true,
    "rewrap.autoWrap.notification": "icon",

    "rust-client.trace.server": "messages",

    "search.searchOnType": false,
    "search.searchOnTypeDebouncePeriod": 5000,
    "search.showLineNumbers": true,

    "shellformat.flag": "-i 2",

    "terminal.integrated.fontSize": 12,
    "terminal.integrated.shell.osx": "/usr/local/bin/fish",

    "typescript.suggest.autoImports": false,
    "typescript.updateImportsOnFileMove.enabled": "never",

    "workbench.editor.closeOnFileDelete": true,
    "workbench.editor.enablePreview": false,
    "workbench.editor.highlightModifiedTabs": true,
    "workbench.editor.labelFormat": "medium",
    "workbench.editor.revealIfOpen": true,
    "workbench.editor.showTabs": true,
    "workbench.tree.indent": 16,
    "workbench.settings.editor": "json",

    "window.restoreWindows": "none",
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
}

Here's a sample that rewraps incorrectly for me...

type LoginUserMutation {
    id: String
    firstName: String
    lastName: String
    username: String
}

type Mutation {
    """
    This is a test. If you type and cause wrapping, it'll remove the indent.
    """
    loginUser(username: String!, password: String!) LoginUserMutation
}

@stkb
Copy link
Owner

stkb commented Mar 24, 2021

I feel like a fool. It's the rewrap.reformat setting. If you turn that off it will stop unindenting, and work fine.

I should have thought of it sooner, but I forget about that setting and am actually planning on removing it.

Anyway yeah that's the problem

@jeremywiebe jeremywiebe marked this pull request as ready for review March 24, 2021 18:16
@jeremywiebe
Copy link
Contributor Author

jeremywiebe commented Mar 24, 2021

Hey, glad we found it. I removed that setting and it works great! I've resolved the merge conflicts and it's good to land as far as I'm concerned! Thanks for your help!

@stkb stkb merged commit c62907d into stkb:master Mar 25, 2021
@stkb
Copy link
Owner

stkb commented Mar 25, 2021

Great, thanks!

@jeremywiebe jeremywiebe deleted the graphql-block-string branch March 25, 2021 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Block String in GraphQL files
2 participants