View Issue Details

IDProjectCategoryView StatusLast Update
0001864JEDI VCL00 JVCL Componentspublic2004-06-25 04:59
ReporteranonymousAssigned Touser72 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001864: Spelling checker does not check last word
DescriptionThe JV spelling checker implementation does not find a misspelled word if the work is at the end of the text, e.g. given the text 'slurm then glagnar', 'slurm' will found as a potential misspelling, but 'glagnar' will not.

Workaround: put a space on the nd of the text
Additional InformationI have started a DUnit test case that exhibits this bug. It is attached.
TagsNo tags attached.

Activities

2004-06-15 13:11

 

DUnit_TestSpell.pas (3,749 bytes)

user72

2004-06-16 02:38

  ~0004562

The following changes seems to resolve the issues you are having (in JvSpellChecker.pas):

function GetNextWord(var S: PAnsiChar; out Word: AnsiString; Delimiters: TSysCharSet): Boolean;
var
  Start: PAnsiChar;
begin
  Word := '';
  Result := (S = nil);
  if Result then
    Exit;
  Start := nil;
  while True do
  begin
    if S^ = #0 then
    begin
      Word := Start;
      Result := Start <> nil;
      Exit;
    end
    else
    if S^ in Delimiters then
    begin
      if Start <> nil then
      begin
        SetString(Word, Start, S - Start);
        Exit;
      end
      else
        while (S^ in Delimiters) and (S^ <> #0) do
          Inc(S);
    end
    else
    begin
      if Start = nil then
        Start := S;
      Inc(S);
    end;
  end;
end;


function TJvDefaultSpellChecker.Next(out StartIndex, WordLength: Integer): WordBool;
var
  S: PChar;
begin
  StartIndex := 0;
  WordLength := 0;
  Result := False;
  if FPosition <= 0 then
    FPosition := 1;
  if FPosition >= Length(FText) then
    Exit;
  S := PChar(Text) + FPosition - 1;
  if (S = nil) or (S^ = #0) or (trim(S) = '') then
    Exit;
  while True do
  begin
    FCurrentWord := '';
    GetNextWord(S, FCurrentWord, Delimiters);
    WordLength := Length(FCurrentWord);
    StartIndex := S - PChar(Text) - WordLength + 1;
    FPosition := StartIndex + WordLength;
    if (FCurrentWord <> '') and not CanIgnore(FCurrentWord) then
    begin
      FSuggestions.Clear;
      Result := not WordExists(FCurrentWord);
      if Result then
      begin
        GetWordSuggestions(FCurrentWord, FSuggestions);
        Break;
      end;
    end;
    if (S = nil) or (S^ = #0) or (trim(S) = '') then
    begin
      Result := False;
      Break;
    end;
  end;
end;

This passes the DUnit tests.

BTW, I'll add the tests to our dev/dunit project as well

user72

2004-06-25 04:59

  ~0004620

No reply, so assuming it works (already in CVS)

Issue History

Date Modified Username Field Change
2004-06-15 13:11 anonymous New Issue
2004-06-15 13:11 anonymous File Added: DUnit_TestSpell.pas
2004-06-16 02:38 user72 Note Added: 0004562
2004-06-16 02:38 user72 Status new => assigned
2004-06-16 02:38 user72 Assigned To => user72
2004-06-25 04:59 user72 Status assigned => resolved
2004-06-25 04:59 user72 Resolution open => fixed
2004-06-25 04:59 user72 Note Added: 0004620