[code][textadept] Match brackets - imp.

From: Procházka Lukáš Ing. <LPr.att.pontex.cz>
Date: Sat, 08 Jun 2019 16:06:18 +0200

Hello Mitchell,

just slight improvement to your "Match Brackets" (Ctrl+M) - to handle also brackets just one pos left of the current cursor pos, if not matched exactly at pos (e.g. text editor TextPad works like that);
to be placed probably into "menu.lua" around ln. 93:

...
     {_L['_Match Brace'], function()
- local match_pos = buffer:brace_match(buffer.current_pos, 0)
- if match_pos >= 0 then buffer:goto_pos(match_pos) end
-
+ local c_pos = buffer.current_pos
+ local pos = buffer:brace_match(c_pos, 0)
+
+ if pos < 0 and c_pos > 0 then pos = buffer:brace_match(c_pos - 1, 0) end
+
+ if pos >= 0 then buffer:goto_pos(pos) end
+
     end},
...

Cheers,

Lukas

-- 
Ing. Lukáš Procházka | mailto:LPr.att.pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS: nrpt3sn | IČO: 40763439
Bezová 1658
147 14 Praha 4
Mob.: +420 702 033 396
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 08 Jun 2019 - 10:06:18 EDT

This archive was generated by hypermail 2.2.0 : Sun 09 Jun 2019 - 06:38:24 EDT