Cmder: Small issue with syntax highlighting in directories with "%20" in their name

Created on 20 Feb 2017  路  20Comments  路  Source: cmderdev/cmder

Any folder with %20 in the name gives the following error D:\cmder\vendor/clink.lua:42: invalid capture index and the syntax highlighting is broken.
image

Bug

Most helpful comment

I added the following functions and replaces all string.gsub by replace:

function explode(separator, str, withpattern)
    if ( withpattern == nil ) then withpattern = false end
    local ret = {}
    local current_pos = 1
    for i = 1, string.len( str ) do
        local start_pos, end_pos = string.find( str, separator, current_pos, not withpattern )
        if ( not start_pos ) then break end
        ret[ i ] = string.sub( str, current_pos, start_pos - 1 )
        current_pos = end_pos + 1
    end
    ret[ #ret + 1 ] = string.sub( str, current_pos )
    return ret
end

function replace( str, tofind, toreplace )
    local tbl = explode( tofind, str )
    if ( tbl[ 1 ] ) then return table.concat( tbl, toreplace ) end
    return str
end

the functions are from https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/string.lua, which have no license attached :-(

All 20 comments

Seems to be this:
http://stackoverflow.com/questions/11008520/putting-in-string-gsub-in-lua

I tried a few ways to escape it, but I wasn't successfull :-/

Ahh that would also explain an issue I'm having with ^. If you try to apply a stash like so git stash apply stash^{/ExampleStash} you get a fatal error. I assume it's a similar issue being that ^ is an operator in lua?

I added the following functions and replaces all string.gsub by replace:

function explode(separator, str, withpattern)
    if ( withpattern == nil ) then withpattern = false end
    local ret = {}
    local current_pos = 1
    for i = 1, string.len( str ) do
        local start_pos, end_pos = string.find( str, separator, current_pos, not withpattern )
        if ( not start_pos ) then break end
        ret[ i ] = string.sub( str, current_pos, start_pos - 1 )
        current_pos = end_pos + 1
    end
    ret[ #ret + 1 ] = string.sub( str, current_pos )
    return ret
end

function replace( str, tofind, toreplace )
    local tbl = explode( tofind, str )
    if ( tbl[ 1 ] ) then return table.concat( tbl, toreplace ) end
    return str
end

the functions are from https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/extensions/string.lua, which have no license attached :-(

want to make a PR?

Do you want the functions which are upstream without a license?

I think it's ok, it's pretty generic.. cc @MartiUK though

I'd give a cautious yes to go ahead, a simple attribution in a comment would be enough I feel.

I'm not anymore using windows, and so also do not use cmder, so I cannot do this PR anymore :-(

Has there been any movement on this issue?

conemu64_2018-05-17_15-09-39
Can't repo :(

I see this is closed, but I want to throw this into the ring. In my case I'm using an SVN(I know) repo, perhaps that's the trick? Running CMDER v1.3.5 (Updated to v1.3.6 and issue persists).

image

Yup, can repro with SVN, thank you!

When downloading from https://ci.appveyor.com/project/MartiUK/cmder/branch/master/artifacts the problem persists. Error reported drops down 5 lines - vendor/clink.lua:335

What is your folder name? You blanked it out in your screenshot.

Tested cmder from previous link on the dirs for both:

  • C:\dev\K188CA163TestDirectory\source
  • C:\dev\test dir\source

So you don't even have % in your path, so it's a different issue. I can't repro with your paths.

conemu64_2018-06-07_16-45-19

I will take a proper look at both issues later.

@Stanzilla Problem persists through on v1.0.698-master. (Apologies for the delay in getting back)

vendor/clink.lua:334: invalid capture index

The SVN repos I'm working with do have %20 in them. Several in fact.

IE: Something like

URL: https://svn.foo.net:2222/svn/projects/clients/foo%20/bar/51487/Project%20Name
Relative URL: ^/projects/clients/foo%20/bar/51487/Project%20Name

conemu64_2018-06-21_16-45-30
馃馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isnullxbh picture isnullxbh  路  3Comments

AaronKaa picture AaronKaa  路  3Comments

justinmchase picture justinmchase  路  3Comments

Joe1992w picture Joe1992w  路  3Comments

spooky picture spooky  路  3Comments