mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 08:58:23 +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;
|
||||
subRange: NSRange;
|
||||
begin
|
||||
if (aRange.location=0) and (params.text='') then begin
|
||||
params.text:= ' ';
|
||||
textWord:= NSSTR( ' ' );
|
||||
Exit;
|
||||
end;
|
||||
|
||||
lineText:= StrToNSString( params.text );
|
||||
subRange.location:= params.col;
|
||||
subRange.length:= aRange.length;
|
||||
if subRange.location + subRange.length > lineText.length then begin
|
||||
if lineText.length > subRange.location then
|
||||
subRange.length:= lineText.length - subRange.location
|
||||
else
|
||||
subRange.length:= 0;
|
||||
if subRange.location >= lineText.length then begin
|
||||
textWord:= NSSTR( ' ' );
|
||||
Exit;
|
||||
end;
|
||||
if subRange.location + subRange.length > lineText.length then
|
||||
subRange.length:= lineText.length - subRange.location;
|
||||
textWord:= lineText.substringWithRange( subRange );
|
||||
end;
|
||||
|
||||
@ -463,6 +457,7 @@ var
|
||||
procedure setActualRange;
|
||||
begin
|
||||
if aRange.location >= (LW_LOCATION_BASE/2) then begin
|
||||
params.length:= textWord.length;
|
||||
actualRange^:= LWParamsToRange( params );
|
||||
end else begin
|
||||
actualRange^.location:= aRange.location;
|
||||
|
Loading…
Reference in New Issue
Block a user