Community
    • Login

    Confusing/Frustrating folding behavior

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 122 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Thorin SchmidtT Offline
      Thorin Schmidt
      last edited by

      Hello,
      Using version 8.9.6.4 s4-bit
      Windows 11
      Language: Python

      I’ve noticed this for awhile, even in previous versions.
      I normally like to keep my functions folded so I can navigate easily, unfolding them as needed, when editing, then folding them back up.

      My issue is that often, not always, but often, once I fold the function back up, the FUNCTION BELOW IT has somehow opened, so I close THAT one and…

      The NEXT one is now unfolded, so I fold that…

      This continues all the way down my file. I will have to manually fold every. single. function. And no, I am not forgetting to fold them up and only noticing it later. I at first thought that was what was happening, but no, they are unfolding on their own. Sure, I can fold them up again, but it is annoying. Also, it doesn’t always happen. Only sometimes.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Thorin Schmidt
        last edited by PeterJones

        @Thorin-Schmidt ,

        That sounds similar to Issue #18093, where the seemingly-random unfolding was happening for a UDL instead of for Python. In that issue, it’s because of the presence of a comment in the second block (but my experiment below shows that’s not the case for the python folding… at least, not the sole cause)

        I don’t know if it’s related or not. Can you share a small piece of code (maybe 3 blocks long) that shows the problem if that’s all you have in the file? For example, I cannot replicate your problem with

        def first():
            more()
            return
        
        def more():
            # commented
            pass
        
        def most():
            first()
            more()
            return
        

        I will have to manually fold every. single. function

        Well, that’s the easy part. Alt+0 folds everything with one keystroke (the default keystroke for View > Fold All).

        Thorin SchmidtT 1 Reply Last reply Reply Quote 0
        • Thorin SchmidtT Offline
          Thorin Schmidt @PeterJones
          last edited by PeterJones

          @PeterJones Thanks for the keyboard shortcut. I’m embarrassed to say I never considered that approach. But here are some function blocks. I’m doing this quick and dirty right now, so forgive the inelegant code.

          (This is for a character generator for an obscure RPG you probably haven’t heard of)

          def get_bonus(self, score):
                  if score > 18:
                      return "+4"
                  elif score > 16:
                      return "+3"
                  elif score > 14:
                      return "+2"
                  elif score > 12:
                      return "+1"
                  elif score > 8:
                      return "+0"
                  else:
                      return "-1"
              
              def roll(self, n=1, d=6):
                  total = 0
                  for i in range(n):
                      total += randint(1, d)
                  return total
              
              #CLASS FUNCTIONS
              def choose_class(self):
                  print(
                  """First, choose your character's class by entering the letter of your choice:
                       
                           WARRIORS       MAGICIANS         SPECIALISTS
                           --------       ---------         -----------
                           A) Amazon      F) Elementalist   K) Hunter
                           B) Barbarian   G) Lyrist         L) Thief
                           C) Centaur     H) Nymph
                           D) Noble       I) Priest
                           E) Spearman    J) Sorceror 
                           """)
                  while True:
                      self.code = ""
                      self.code = input("Your Choice [A-L]: ")[0].upper()
                      if self.code in "ABCDEFGHIJKL":
                          break
                  
                  match self.code:
                      case "A": 
                          self.char_class = "Amazon"
                          self.primary = Stat.SKILL
                          self.secondary = Stat.GRACE
                      case "B":
                          self.char_class = "Barbarian"
                          self.primary = Stat.MIGHT
                          self.secondary = Stat.WILL
                      case "C":
                          self.char_class = "Centaur"
                          self.primary = Stat.MIGHT
                          self.secondary = Stat.SKILL
                      case "D":
                          self.char_class = "Noble"
                          self.primary = Stat.LUCK
                          self.secondary = Stat.OTHER
                      case "E":
                          self.char_class = "Spearman"
                          self.primary = Stat.SKILL
                          self.secondary = Stat.WILL
                      case "F":
                          self.char_class = "Elementalist"
                          self.primary = Stat.WILL
                          self.secondary = Stat.WITS
                      case "G":
                          self.char_class = "Lyrist"
                          self.primary = Stat.GRACE
                          self.secondary = Stat.LUCK
                      case "H":
                          self.char_class = "Nymph"
                          self.primary = Stat.GRACE
                          self.secondary = Stat.LUCK
                      case "I":
                          self.char_class = "Priest"
                          self.primary = Stat.WILL
                          self.secondary = Stat.LUCK
                      case "J":
                          self.char_class = "Sorceror"
                          self.primary = Stat.WILL
                          self.secondary = Stat.WITS
                      case "K":
                          self.char_class = "Hunter"
                          self.primary = Stat.SKILL
                          self.secondary = Stat.WITS
                      case "L":
                          self.char_class = "Thief"
                          self.primary = Stat.WITS
                          self.secondary = Stat.LUCK
                      case _:
                          # Default action if no other case matches
                          print("ERROR")
                          exit()
          
          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors