Repository: vscode
Issue: [folding] Remove manual folding range should only remove most inner folding range
Labels: help wanted,feature-request,editor-folding

Type: <b>Bug</b>

https://github.com/microsoft/vscode/assets/12509132/705bf059-74df-4144-904b-fde23dbd232a

1) I made a manual folding range, then another manual folding range including the first one (on ## IMPORT)

2) Tried to remove the first one. It removed the second one (the outer one). Tried to remove first one again, but it sticks.

<details>
<summary>code in mod-server.py</summary>

```py
## IMPORT
# libs
import socket
import os
import sys
import time
import zipfile

# functions
from os.path import exists

## CONFIGURATION
server_configs = ["fiote.mods.bossdirections", "shudnal.NomapPrinter"]
server_excludes = ["ValheimPlus", "ServerSync"]  # plugins
client_plugins = ["CustomLoadingScreens"]
client_configs = ["aedenthorn.CustomLoadingScreens"]

## FUNCTIONS
def get_ip():
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  s.connect(("8.8.8.8", 80))
  return s.getsockname()[0]

def prepare(outfile): # fetches plugins/configs from server primarily and client specifically
  ## DEFS  
  # user consts
  global server_configs, server_excludes, client_configs, client_plugins
  
  # parameter consts
  compression = zipfile.ZIP_DEFLATED # .ZIP_STORED for no comp
  
  # paths
  server_path = "d:/education/valheim-server/"
  client_path = "d:/steam-library/steamapps/common/valheim/"

  path_base     = "bepinex/"

  path_configs  = path_base + "config/"
  path_plugins  = path_base + "plugins/"
  path_core     = path_base + "core/"
  path_patchers = path_base + "patchers/"

  # install bepinex libs
  path_bep_1    = "winhttp.dll"
  path_bep_2    = "unstripped_corlib/"
  path_bep_3    = "doorstop_libs/"
  
  ## INIT
  zip = zipfile.ZipFile(outfile, mode="w")
  
  ## HELPER FUNCTIONS
  def write(path):
    zip.write(path, compress_type=compression)
  def recwrite(path):
    print("root: " + path)
    for path, dirs, files in os.walk(path):
      if check_exclusion(path): continue
      print("|_write root: " + path)
      write(path)
      for file in files:
        print("|_write file: " + file)
        write(path + "/" + file)
      for dir in dirs:
        if os.path.basename(os.path.normpath(dir)) in server_excludes: continue
        recwrite(dir)

  def check_exclusion(path):
    skip = False
    for exclude in server_excludes:
      if exclude in path:
        skip = True
        break
    return skip

  ## HANDLE CLIENT PLUGINS/CONFIGS
  os.chdir(client_path)
  print("changed working folder: " + client_path)
  for plugin in client_plugins:
    print("writing client plugin: " + plugin)
    recwrite(path_plugins + plugin)

  client_configs = [config.replace(".cfg","") + ".cfg" for config in client_configs]
  for config in client_configs:
    print("writing client config: " + config)
    write(path_configs + config)

  ## HANDLE SERVER
  os.chdir(server_path)
  print("changed working folder: " + server_path)
  server_configs = [config.replace(".cfg","") + ".cfg" for config in server_configs]
  for config in server_configs:
    print("writing config: " + config)
    write(path_configs + config)

  recwrite(path_plugins)
  recwrite(path_core)
  recwrite(path_patchers)

  write(path_bep_1)
  recwrite(path_bep_2)
  recwrite(path_bep_3)

  zip.close()
  
  update_filesize()
def update_filesize():
  global filesize
  filesize = str(os.stat(zip_path).st_size)
  while len(filesize) < 32:
    filesize = " " + filesize

## MAIN
# defs
home_path = sys.path[0]
zip_path = home_path + "/bepinex.zip"

host = get_ip()
port = 7777

# code
s = socket.socket()
s.bind((host,port))
s.listen(1)
s.setblocking(0)
os.system('cls')
print("welcome to mod-server")
filesize = ""
print("listening for clients...")
alert = " "
while True:
  time.sleep(1)

  if exists("d:/education/valheim-server/halt.txt"):
    os.remove("d:/education/valheim-server/halt.txt")
    break

  # handle clients
  try:
    c, addr = s.accept()
    print("connection from: " + str(addr))
    print("creating zip file with plugins to send to clients...")
    prepare(zip_path)
    print("zip done, sending...")
    c.send(filesize.encode())
    myfile = open(zip_path, "rb")
    c.send(myfile.read())
    c.close()
    myfile.close()
    time.sleep(1)
    os.system('cls')
    print("file has been sent to " + str(addr))
    print("listening for clients...")

  except:
    alert = "|" if alert == "\\" else ("\\" if alert == "—" else ("—" if alert == "/" else "/"))
#    print(" working "+alert,end="\r") # disabled for logging purposes
```

</details>

VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:13:33.891Z)
OS version: Windows_NT x64 10.0.19045
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz (4 x 3498)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|undefined|
|Memory (System)|15.94GB (7.62GB free)|
|Process Argv|D:\\education\\valheim-server\\mod-server.py --crash-reporter-id a15f87e6-34f2-49ba-9e90-491ecb2e9885|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (17)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-autohotkey-plus|cwe|2.7.1
vscode-notepad|dev|0.1.2
language-julia|jul|1.79.2
vsc-python-indent|Kev|1.18.0
csharp|ms-|2.28.11
vscode-dotnet-runtime|ms-|2.0.5
debugpy|ms-|2024.6.0
isort|ms-|2023.10.1
python|ms-|2024.6.0
vscode-pylance|ms-|2024.5.1
hexeditor|ms-|1.10.0
powershell|ms-|2024.2.1
kb-macro|tsh|0.13.15
intellicode-api-usage-examples|Vis|0.2.8
vscodeintellicode|Vis|1.3.1
material-theme|zhu|3.17.2
vscode-zig|zig|0.5.7

(13 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
tftest:31042121
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
showvideoc:31016891
dsvsc021:30996838
bdiig495:31013172
dwnewjupyter:31039675

```

</details>

<!-- generated by issue reporter -->