Menu

#1144 Add folding support for shell

Committed
closed
nobody
5
2019-01-11
2016-04-09
b2f9h203
No

Currently in SciTE there seems to be almost no support for code folding in shell scripts (.sh). The only things which can be folded are comments starting with # and function bodies(?) surrounded by braces. It would be very helpful if things like if, while, elif could also be folded.

Discussion

  • Kein-Hong Man

    Kein-Hong Man - 2016-04-20

    I'm to blame for a lot of the Bash/shell highlighting updates.
    Anyway, I would welcome anyone who wishes to contribute a patch for this feature request.
    Currently I cannot promise any updates on any timeline, but I will put this on my list.

     
  • Zufu Liu

    Zufu Liu - 2018-09-02

    A rather simple fix is to enable folding for if (fi), case (esac) and do (done).

     
    • Colomban Wendling

      Looks good to me, I just have a few small code improvement suggestsions, see the alternative diff attached (based on yours).

      • Don't collect more than 8 byte per words, we don't need more and it's faster and cheaper memory-wise not to.
      • If collecting would overflow, just stop collection: we're not interested in the word anyway as it won't match anything useful.
      • use if (styleNext != style) as a canonical way of meaning if style changes, instead of repeating the style ID.

      Apart from that, an extra improvement would be folding on else and }{ but that can easily be a second step.

       
      • Kein-Hong Man

        Kein-Hong Man - 2018-09-02

        I'll leave the improvement patch in both of your good hands. I am busy with other stuff and will be lurking for a few months yet, so have fun guys. :-)

         
      • Zufu Liu

        Zufu Liu - 2018-09-02

        looks good than my patch. But wordlen < sizeof(word) need change to wordlen < sizeof(word) - 1, otherwise buffer overrun at word[wordlen] = '\0';.

         

        Last edit: Zufu Liu 2018-09-02
        • Colomban Wendling

          Oops, you're of course right. Updated patch (using (wordlen + 1) < sizeof(word)) attached.

           
          • Neil Hodgson

            Neil Hodgson - 2018-09-04

            Committed as [54561e].

             

            Related

            Commit: [54561e]

  • Neil Hodgson

    Neil Hodgson - 2018-09-04
    • labels: --> scintilla, folder, shell
    • Group: Completed --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2019-01-11
    • 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.