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

[BUG] [docstrings] [vscode] Weird behaviour when using double backslashes with newline separators and inserting mojo code #2721

Open
martinvuyk opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working Initiative: Documentation mojo-repo Tag all issues with this label

Comments

@martinvuyk
Copy link

martinvuyk commented May 17, 2024

Bug description

This underlines the last 3 mojo examples in red and says unterminated backtick identifier though they still generate correctly when hovering over the function name

    fn split[
        maxsplit: Int = -1
    ](self, owned delimiter: String = "") -> List[String]:
        """Split the string by a delimiter. This defaults to universal
        newlines [just as Python](https://docs.python.org/3/library/stdtypes.html).
 
        Parameters:
            maxsplit: The maximum amount of items to split from String.
                Defaults to unlimited.
 
        Args:
            delimiter: The string to split on.
 
        Returns:
            A List of Strings containing the input split by the delimiter.
 
        Examples:
 
        Splitting a space:
 
        ```mojo
        var s = String("hello world").split(" ") # ["hello", "world"]
        ```

        Splitting adjacent delimiters:

        ```mojo
        var s = String("hello,,world").split(",") # ["hello", "", "world"]
        ```
 
        Splitting adjacent universal newlines:
 
        ```mojo
        var s = String("hello \\t\\n\\r\\f\\v\\x1c\\x1e\\x85world").split() # ["hello", "world"]
        ```

        Splitting with maxsplit:

        ```mojo
        var s = String("1,2,3").split[maxsplit=1](",") # ['1', '2,3']
        ```
 
        Splitting an empty string or filled with whitespaces:
 
        ```mojo
        var s = String(" ").split() # []
        var s = String("").split() # []
        ```

        Splitting a string full of the delimiter:

        ```mojo
        var s = String(",,,").split(",") # ["", "", "", ""]
        ```
        .
        """
        ....

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
`mojo 2024.5.1705`
mojo nightly vscode extension `v2024.5.1705`
- Provide Modular CLI version by pasting the output of `modular -v`
@martinvuyk martinvuyk added bug Something isn't working mojo-repo Tag all issues with this label labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Initiative: Documentation mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants