Page 1 of 1

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

Posted: 16.09.2022 14:20
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

Posted: 16.09.2022 19:45
by main Alexey

Posted: 10.10.2022 07:24
by kvichans
Done