Skif-off left a comment (geany/geany-plugins#1527)

> It seems to me that in this case the best solution would be to use built-in 
> commands, but need to find a way to select the block in which the cursor is 
> located.

I can't do it because I don't fully understand how folding works in Scintilla :(
Maybe the Geany developers will find it interesting to add such a feature to 
the editor. Or they will show an example (not necessarily in Lua) :)

The current version of my attempt (unstable):
```lua
-- (cross-platform)
--2025.12.11
--[[
Details: https://github.com/geany/geany-plugins/issues/1527

Selects the text inside the current folding block.
]]

-- Current line
local iL, _ = geany.rowcol()
-- Line number of the start of the folding block
local iFB  = geany.scintilla("SCI_GETFOLDPARENT", iL - 1)
if iFB == -1 then
  geany.message("Not found or other problem. Exit.")
  return
end
-- Position at the start of the line
local iSB  = geany.scintilla("SCI_POSITIONFROMLINE", iFB)

-- Line number of the end of the folding block
-- local iFE = geany.scintilla("SCI_GETLASTCHILD", iL - 1, -1)
-- I didn't understand or failed, so we will forget about SCI_GETLASTCHILD
-- and will stupidly search for the same fold level as the current line
local iFE, iT
local iFL = geany.scintilla("SCI_GETFOLDLEVEL", iL - 1)
local iN = geany.height() - 1
for i = iL, iN do
  iT = geany.scintilla("SCI_GETFOLDLEVEL", i)
  if iT < iFL then
    iFE = i - 1
    break
  end
end
-- Position at the end of the line, before any line end characters
local iSE = geany.scintilla("SCI_GETLINEENDPOSITION", iFE)

-- Select block
geany.select(iSB, iSE)
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1527#issuecomment-3642366326
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany-plugins/issues/1527/[email protected]>

Reply via email to