lundmark / textadept_swm

Selected Word Marker for the TextAdept editor.
0 stars 0 forks source link

Module not compatible with version 11 of Textadept #1

Open julien1001 opened 3 years ago

julien1001 commented 3 years ago

Version 11 of Textadept introduced a change in buffer indexing: https://orbitalquark.github.io/textadept/manual.html#migrating-from-textadept-10-to-11

Because of this, textadept_swm does not work properly with this version. Once a word is selected, the other occurrences of the same word are not properly highlighted (the rectangle starts and finishes with 1 character in advance).

Below the patch fixing the issue.

---
 init.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init.lua b/init.lua
index 71120a4..bdce3aa 100644
--- a/init.lua
+++ b/init.lua
@@ -73,7 +73,7 @@ local function update_marker_selection()
                                local letter_after = string.sub(buffer_text, found_end+1, found_end+1)
                                if (not letter_before or allowed_characters[letter_before]) and
                                        (not letter_after or allowed_characters[letter_after]) then
-                                       buffer:indicator_fill_range(found_start-1, found_end - found_start+1)
+                                       buffer:indicator_fill_range(found_start, found_end - found_start+1)
                                end
                                found_start, found_end = string.find(buffer_text, selected_text, index, true)
                        end
-- 
lundmark commented 3 years ago

Hey nice, I haven't even noticed this issue nor have I used textadept in many years! Thanks for the patch :) I'll try to apply it!