Skip to content

Commit de0a837

Browse files
author
livecodeali
committed
[[ Bug 16647 ]] Don't under-run the existing mark in wholechunk marking mode
1 parent 645caba commit de0a837

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

docs/notes/bugfix-16647.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Delete only chunk in line should not delete line

engine/src/exec-strings-chunk.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void MCStringsMarkTextChunkInRange(MCExecContext& ctxt, MCStringRef p_string, MC
289289
r_end += t_found_range . length;
290290
// If we didn't, and this operation does not force additional delimiters, then include the previous delimiter in the mark.
291291
// e.g. mark item 3 of a,b,c -> a,b(,c) so that delete item 3 of a,b,c -> a,b
292-
else if (r_start > 0 && !r_add)
292+
else if (r_start > p_range . offset && !r_add)
293293
r_start -= t_found_range . length;
294294
}
295295
}
@@ -359,7 +359,7 @@ void MCStringsMarkTextChunkInRange(MCExecContext& ctxt, MCStringRef p_string, MC
359359
{
360360
if (r_end >= 0 && (uindex_t) r_end < t_length)
361361
r_end++;
362-
else if (r_start > 0 && !r_add)
362+
else if (r_start > p_range . offset && !r_add)
363363
r_start--;
364364
}
365365
}
@@ -423,7 +423,7 @@ void MCStringsMarkTextChunkInRange(MCExecContext& ctxt, MCStringRef p_string, MC
423423
// and word chunk range goes to the end of the string.
424424
if (r_end >= 0 && (uindex_t) r_end == t_length)
425425
{
426-
while (r_start > 0 && MCUnicodeIsWhitespace(MCStringGetCharAtIndex(p_string, r_start - 1)))
426+
while (r_start > p_range . offset && MCUnicodeIsWhitespace(MCStringGetCharAtIndex(p_string, r_start - 1)))
427427
r_start--;
428428
}
429429
return;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
script "CoreChunksText"
2+
/*
3+
Copyright (C) 2015 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestDeleteSegmentOfLine
20+
local tLines
21+
put "a" & return & "b" & return & "c" into tLines
22+
delete word 1 of line 2 of tLines
23+
TestAssert "delete word of line comprising word does not delete line", the number of lines in tLines is 3
24+
end TestDeleteSegmentOfLine
25+
26+
on TestDeleteItemOfLine
27+
local tLines
28+
put "a" & return & "b" & return & "c" into tLines
29+
delete item 1 of line 2 of tLines
30+
TestAssert "delete item of line comprising item does not delete line", the number of lines in tLines is 3
31+
end TestDeleteItemOfLine

0 commit comments

Comments
 (0)