Skip to content

Commit

Permalink
fixed spacing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
digital-phoenix committed Jan 19, 2024
1 parent bda9075 commit f375070
Showing 1 changed file with 29 additions and 35 deletions.
64 changes: 29 additions & 35 deletions MultilineGreyText/MultilineGreyTextTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,45 +70,39 @@ private InlineGreyTextTagger GetTagger(){
}

public void SetSuggestion(String newSuggestion, bool inline, int caretPoint){
ClearSuggestion();
inlineSuggestion = inline;

int lineN = GetCurrentTextLine();

if (lineN < 0) return;

String untrim = buffer.CurrentSnapshot.GetLineFromLineNumber(lineN).GetText();
String line = untrim.TrimStart();
int offset = untrim.Length - line.Length;

ClearSuggestion();
inlineSuggestion = inline;

int lineN = GetCurrentTextLine();

if (lineN < 0) return;

String untrim = buffer.CurrentSnapshot.GetLineFromLineNumber(lineN).GetText();
String line = untrim.TrimStart();
int offset = untrim.Length - line.Length;

caretPoint = Math.Max(0, caretPoint - offset);

String currentText = line.Substring(0, caretPoint);
String combineSuggestion = currentText + newSuggestion;
String combineSuggestion = line + newSuggestion;
if (line.Length - caretPoint > 0){
String currentText = line.Substring(0, caretPoint);
combineSuggestion = currentText + newSuggestion;
userEndingText = line.Substring(caretPoint).TrimEnd();
var userIndex = newSuggestion.IndexOf(userEndingText);
if (userIndex < 0){
return;
}
userIndex += currentText.Length;

if (line.Length - caretPoint > 0){

userEndingText = line.Substring(caretPoint).TrimEnd();
if (String.IsNullOrEmpty(userEndingText)){
this.userIndex = userIndex;
isTextInsertion = true;
insertionPoint = line.Length - caretPoint;
}else{
isTextInsertion = false;
}

}else{
var userIndex = newSuggestion.IndexOf(userEndingText);
if (userIndex < 0)
{
return;
}
userIndex += currentText.Length;
this.userIndex = userIndex;
}

isTextInsertion = true;
insertionPoint = line.Length - caretPoint;
}else{
isTextInsertion = false;
}

suggestion = new Tuple<String, String[]>(combineSuggestion, combineSuggestion.Split('\n'));
Update();
suggestion = new Tuple<String, String[]>(combineSuggestion, combineSuggestion.Split('\n'));
Update();
}

private void CaretUpdate(object sender, CaretPositionChangedEventArgs e){
Expand Down

0 comments on commit f375070

Please sign in to comment.