Menu

#1504 Feature Request: Open Selected Filename starting with tilde/home path

Committed
closed
nobody
5
2023-12-25
2023-11-23
No

Issue

Currently SciTE command Open Selected Filename(<dbd>Ctrl</dbd>+<dbd>Shift</dbd>+<dbd>O</dbd>) opens:

  • /home/username/path/to/myfile.txt
  • /home/username/.SciTEUser.properties
  • ./path/to/myfile.txt

But it doesn't open:

  • ~/path/to/myfile.txt
  • ~/.SciTEUser.properties
  • $HOME/.SciTEUser.properties
  • ${HOME}/.SciTEUser.properties
  • ./config/settings${ENVIRONMENTT}.ini

This patch allows SciTE to open the paths starting with tilde:

❯ hg status
M src/SciTEIO.cxx
❯ hg diff
diff -r 9e0343bf65b4 src/SciTEIO.cxx
--- a/src/SciTEIO.cxx   Tue Nov 21 19:24:16 2023 +1100
+++ b/src/SciTEIO.cxx   Thu Nov 23 19:21:56 2023 -0300
@@ -686,6 +686,13 @@
                }
        }

+       if (StartsWith(selName, "~/")) {
+               selName.erase(0, 2);
+               FilePath selPath(GUI::StringFromUTF8(selName));
+               FilePath expandedPath = FilePath(FilePath::UserHomeDirectory(), selPath);
+               selName = expandedPath.AsInternal();
+       }
+
        std::string fileNameForExtension = ExtensionFileName();
        std::string openSuffix = props.GetNewExpandString("open.suffix.", fileNameForExtension);
        selName += openSuffix;
@@ -1645,4 +1652,3 @@
                OutputAppendStringSynchronised(sExitMessage);
        }
 }
-
1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2023-11-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -42,4 +42,4 @@
             }
      }
     -
    -``
    +```
    
     
  • Neil Hodgson

    Neil Hodgson - 2023-11-24
    • Group: Initial --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2023-11-24

    Committed with small changes (AsInternal returns a wide character string on Windows) as [59ce72].

     

    Related

    Commit: [59ce72]

  • Neil Hodgson

    Neil Hodgson - 2023-12-25
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.