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

Request: Do not require quotes #12

Open
dander401 opened this issue Apr 6, 2017 · 3 comments
Open

Request: Do not require quotes #12

dander401 opened this issue Apr 6, 2017 · 3 comments

Comments

@dander401
Copy link

Love this extension, and was hoping to use it for markdown editing as well as my angular development. Only problem is that definitions are not found unless the file path is in quotes... which breaks mark down links.

@abierbaum
Copy link
Owner

@dander401 I don't do any markdown editing with links. Can you suggest a change and test it out? I would definitely accept a pull request that adds support.

@dander401
Copy link
Author

I don't know how to test changes to extensions in VS code, but it looks like it would be a change to reg ex on extension.ts line 99 would do the trick. Mark down links are surrounded by () so adding an or statement to the regex should do it

// We are looking for strings with filenames
// - simple hack for now we look for the string with our current word in it on our line
//   and where our cursor position is inside the string
// -- -- a simple extra or to the reg ex
let re_str = `\"(.*?${word}.*?)\"|\'(.*?${word}.*?)\'|\((.*?${word}.*?)\)`;
let match = line.text.match( re_str );

here is a function to maintain a list of the surrounded matches that might be a bit more manageable

// We are looking for strings with filenames
// - simple hack for now we look for the string with our current word in it on our line
//   and where our cursor position is inside the string
// -- -- a for loop to add extra pairs
function getWordRegEx( word: string ) {
    let i;
    let ret = '';
    // pairs of characters that will wrap a file path
    let terminatingChars: Array<Array<string>> = [
        [ '\"', '\"' ],
        [ '\'', '\'' ],
        [ '\(', '\)' ]
    ];
    // loop through each set of pairs, and or the regexs
    for ( i = 0; i < terminatingChars.length; i++ ) {
        if ( i > 0 ) {
            ret += '|';
        }
        let pair = terminatingChars[ i ];
        ret += `${pair[ 0 ]}(.*?${word}.*?)\"${pair[ 1 ]}`;
    }
    return ret;
}

let re_str = getWordRegEx( word );
let match = line.text.match( re_str );

If you can tell me a good way to test this, I'm cool doing it. Just let me know how I can help

@vrokolos
Copy link

can you please add support for double quotes for use in xml attributes and >< for use in xml elements?

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

No branches or pull requests

3 participants