mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 19:59:24 +02:00
Cocoa: fix the issue with abnormal parameters passed into Lookup Word from macOS
This commit is contained in:
parent
3195a1ab46
commit
8f49ff3eaa
@ -426,21 +426,15 @@ var
|
|||||||
lineText: NSString;
|
lineText: NSString;
|
||||||
subRange: NSRange;
|
subRange: NSRange;
|
||||||
begin
|
begin
|
||||||
if (aRange.location=0) and (params.text='') then begin
|
|
||||||
params.text:= ' ';
|
|
||||||
textWord:= NSSTR( ' ' );
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
lineText:= StrToNSString( params.text );
|
lineText:= StrToNSString( params.text );
|
||||||
subRange.location:= params.col;
|
subRange.location:= params.col;
|
||||||
subRange.length:= aRange.length;
|
subRange.length:= aRange.length;
|
||||||
if subRange.location + subRange.length > lineText.length then begin
|
if subRange.location >= lineText.length then begin
|
||||||
if lineText.length > subRange.location then
|
textWord:= NSSTR( ' ' );
|
||||||
subRange.length:= lineText.length - subRange.location
|
Exit;
|
||||||
else
|
|
||||||
subRange.length:= 0;
|
|
||||||
end;
|
end;
|
||||||
|
if subRange.location + subRange.length > lineText.length then
|
||||||
|
subRange.length:= lineText.length - subRange.location;
|
||||||
textWord:= lineText.substringWithRange( subRange );
|
textWord:= lineText.substringWithRange( subRange );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -463,6 +457,7 @@ var
|
|||||||
procedure setActualRange;
|
procedure setActualRange;
|
||||||
begin
|
begin
|
||||||
if aRange.location >= (LW_LOCATION_BASE/2) then begin
|
if aRange.location >= (LW_LOCATION_BASE/2) then begin
|
||||||
|
params.length:= textWord.length;
|
||||||
actualRange^:= LWParamsToRange( params );
|
actualRange^:= LWParamsToRange( params );
|
||||||
end else begin
|
end else begin
|
||||||
actualRange^.location:= aRange.location;
|
actualRange^.location:= aRange.location;
|
||||||
|
Loading…
Reference in New Issue
Block a user