From b029f5993edb7dee5ccd2ba55faac1ec22e24609 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 2 Nov 2022 21:11:41 +0100 Subject: [PATCH] Don't sort in `Doc:get_selection_idx` with an invalid index --- data/core/doc/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index e3ea4b92..26fc2a52 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -168,7 +168,7 @@ end ---@return integer,integer,integer,integer,boolean? @line1, col1, line2, col2, was the selection sorted function Doc:get_selection_idx(idx, sort) local line1, col1, line2, col2 = self.selections[idx*4-3], self.selections[idx*4-2], self.selections[idx*4-1], self.selections[idx*4] - if sort then + if line1 and sort then return sort_positions(line1, col1, line2, col2) else return line1, col1, line2, col2