In CudaExt "Open file by selected name" replace "%20" to " "

Plugins for SynWrite and CudaText...
Post Reply
king.midas
Posts: 40
Joined: 26.02.2019 13:47

In CudaExt "Open file by selected name" replace "%20" to " "

Post by king.midas »

Hello!
In CudaExt exists command "Navigate - Open file by selected name".
Local markdown files with links with spaces can contain "%20", that command does not open.
Example:

Code: Select all

[Example](../Files/Example%20Test.md)
If in "cd_ext.py" change code(may be ugly...) in function "def open_selected()" to:

Code: Select all

        for bs_dir in bs_dirs:
            op_file     = os.path.join(bs_dir, pointed)
            op_row      = -1
            if not os.path.isfile(op_file) and \
               '(' in op_file:                                      #)
                    # Try to split in 'path(row'                    #)
                    mtch= re.search(r'(.*)\((\d+)', op_file)
                    if mtch:
                        pointed_,op_row = mtch.groups()
                        op_row          = int(op_row)
                        op_file         = os.path.join(bs_dir, pointed_)
            if os.path.isfile(op_file):
                op_ed   = _file_open(op_file)
                op_ed.focus()
                if op_row!=-1:
                    op_ed.set_caret(0, op_row)
                break#for
            ### ++++++++++++++++++
            op_file_norm = op_file.replace("%20", " ")
            if not os.path.isfile(op_file_norm) and \
               '(' in op_file_norm:                                      #)
                    # Try to split in 'path(row'                    #)
                    mtch= re.search(r'(.*)\((\d+)', op_file_norm)
                    if mtch:
                        pointed_,op_row = mtch.groups()
                        op_row          = int(op_row)
                        op_file_norm         = os.path.join(bs_dir, pointed_)
            if os.path.isfile(op_file_norm):
                op_ed   = _file_open(op_file_norm)
                op_ed.focus()
                if op_row!=-1:
                    op_ed.set_caret(0, op_row)
                break#for
            ### --------------------------
file opens!

If possible, please add a treatment for this situation
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

User avatar
kvichans
Posts: 203
Joined: 07.10.2012 05:45

Post by kvichans »

Done
CudaText 1.163, TC9.51x32, Win10x64(1920x1080)
Post Reply