Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.49k stars 170 forks source link

CSS autocomplete places semicolon behind brackets #5414

Closed d-mal closed 7 months ago

d-mal commented 7 months ago

With CSS, when you are inside the curly braces of div {} and start typing div {mar} and then press Ctrl-Space to get the autocomplete window, chose "margin", and the result will be div {margin: };

The semicolon is placed at the end of the line, but that's an error if it's behind closing braces. Maybe it can be checked if the last character is a } and in that case the semicolon goes in front of the last character?

Alexey-T commented 7 months ago

found the src part which is to fix: atsynedit_cmp_css.pas

procedure TAcp.DoOnChoose(Sender: TObject; const ASnippetId: string;
  ASnippetIndex: integer);
var
  St: TATStrings;
  Caret: TATCaretItem;
  S: UnicodeString;
begin
  St:= Ed.Strings;
  if CompletionOpsCss.AppendSemicolon then
  begin
    if Ed.Carets.Count=0 then exit;
    Caret:= Ed.Carets[0];
    if not St.IsIndexValid(Caret.PosY) then exit;
    S:= St.Lines[Caret.PosY];
    if S='' then exit;
    if S[Length(S)]<>';' then
    begin
      S+= ';';
      St.Lines[Caret.PosY]:= S;
      Ed.DoEventChange(Caret.PosY);
      Ed.Update;
    end;
  end;
end;
Alexey-T commented 7 months ago

fix is made; you can tell me your 'info from About window' if you need the beta version.

d-mal commented 7 months ago

You are honestly amazing! Thanks for offering a beta, but I don't need this urgently, I'll wait until there is a new release.

Alexey-T commented 7 months ago

thanks for your report, too. I will be glad to get more bugreports...