Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed rpc issue #22

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c4dfe37
adding files for refact extension
Oct 27, 2023
64a5f05
testing github workflow
Oct 30, 2023
91f6717
removing default exe to test workflow
Oct 30, 2023
8dbd51e
uploading artifacts in workflow
Oct 30, 2023
1495fe4
readding exe
Oct 30, 2023
567dba0
cleaning up files
Nov 1, 2023
afd128e
C/C++ now works with grey text
Nov 2, 2023
faa87c6
fixed minor typo
Nov 2, 2023
37e9e90
can now select intellisense options, whitespace causes less problems …
Nov 7, 2023
c477f10
removing binary and updating build scripts
Nov 8, 2023
3153d7a
fixing build script typo
Nov 8, 2023
becfe12
fixing minor build naming issue
Nov 8, 2023
2cfa582
Updating code to be consistent with new build script
Nov 8, 2023
28de23e
improved the options page
Nov 8, 2023
d35bd9c
added comments and fixed formatting
Nov 13, 2023
8b50fb9
updating enter behaviour
Nov 17, 2023
b5e9ea3
fixing minor bugs and functional issues
Nov 21, 2023
ff548ad
added code to fix issues around single vs multiline completions issue…
Nov 30, 2023
341cc2b
added scroll bars for the options page
Nov 30, 2023
f965f5c
adding status bar and killing server process on shutdown
Dec 5, 2023
fc9ba10
fixing minor bug where grey text was inserted into incorrect places
Dec 5, 2023
6421422
Merge remote-tracking branch 'upstream/main'
Dec 5, 2023
d36ac11
Merge branch 'smallcloudai:main' into main
digital-phoenix Dec 27, 2023
33a706c
Update RefactLanguageClient.cs
digital-phoenix Dec 27, 2023
da10582
resolved potential issues
Dec 27, 2023
7254221
Update RefactLanguageClient.cs
digital-phoenix Dec 29, 2023
6b8e02f
Update RefactLanguageClient.cs
digital-phoenix Dec 29, 2023
b8f550d
Update RefactLanguageClient.cs
digital-phoenix Dec 29, 2023
04bbc3a
fixed issues for issue #19
Jan 4, 2024
3862160
Update RefactLanguageClient.cs
digital-phoenix Jan 4, 2024
9d181d7
Merge branch 'main' into main
digital-phoenix Jan 10, 2024
bda9075
fixed all the bugs
digital-phoenix Jan 17, 2024
f375070
fixed spacing issue
digital-phoenix Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed all the bugs
  • Loading branch information
digital-phoenix committed Jan 17, 2024
commit bda9075b05b084aba9a76398ca29801abf38f594
45 changes: 26 additions & 19 deletions MultilineGreyText/MultilineGreyTextTagger.cs
Original file line number Diff line number Diff line change
@@ -81,20 +81,26 @@ public void SetSuggestion(String newSuggestion, bool inline, int caretPoint){
String line = untrim.TrimStart();
int offset = untrim.Length - line.Length;

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

String combineSuggestion = line + newSuggestion;
caretPoint = Math.Max(0, caretPoint - offset);

String currentText = line.Substring(0, caretPoint);
String combineSuggestion = currentText + newSuggestion;

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

userEndingText = line.Substring(caretPoint).TrimEnd();
if (String.IsNullOrEmpty(userEndingText)){

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

this.userIndex = userIndex;
isTextInsertion = true;
insertionPoint = line.Length - caretPoint;
}else{
@@ -455,15 +461,16 @@ public bool CompleteText(){
//replaces text in the editor
void ReplaceText(string text, int lineN){
ClearSuggestion();

SnapshotSpan span = this.snapshot.GetLineFromLineNumber(lineN).Extent;
ITextEdit edit = view.TextBuffer.CreateEdit();
if(span.Length == 0){
edit.Insert(span.Start.Position, text);
}else {
edit.Replace(span, text);
}
edit.Apply();
ITextEdit edit = view.BufferGraph.TopBuffer.CreateEdit();
var spanLength = span.Length;
edit.Replace(span, text);
var newSnapshot = edit.Apply();

if(spanLength == 0 && text.Length > 0){
view.Caret.MoveToPreviousCaretPosition();
view.Caret.MoveToNextCaretPosition();
}
}

//sets up the suggestion for display
28 changes: 20 additions & 8 deletions MultilineGreyText/RefactLanguageClient.cs
Original file line number Diff line number Diff line change
@@ -152,12 +152,12 @@ public async Task<Connection> ActivateAsync(CancellationToken token){
info.CreateNoWindow = true;

//starts the lsp process
Process process = new Process();
process.StartInfo = info;
serverProcess = new Process();
serverProcess.StartInfo = info;

if (process.Start()){
if (serverProcess.Start()){
//returns the connection for future use
this.c = new Connection(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
this.c = new Connection(serverProcess.StandardOutput.BaseStream, serverProcess.StandardInput.BaseStream);
return c;
}

@@ -185,7 +185,6 @@ public async Task OnLoadedAsync(){
if (StartAsync != null){
loaded = true;
await StartAsync.InvokeAsync(this, EventArgs.Empty);
statusBar = new StatusBar();
}
}

@@ -298,24 +297,37 @@ public async Task<string> RefactCompletion(PropertyCollection props, String file

async void ShowDefaultStatusBar(){
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
if (!statusBar.IsInitialized()){
statusBar.InitStatusBar();
}
statusBar.ShowDefaultStatusBar();
}

async void ShowStatusBarError(String error){
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
if (!statusBar.IsInitialized()){
statusBar.InitStatusBar();
}
statusBar.ShowStatusBarError(error);
}

async void ShowLoadingStatusBar(){
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
if (!statusBar.IsInitialized()){
statusBar.InitStatusBar();
}
statusBar.ShowLoadingSymbol();
}

public void Dispose(){
if(serverProcess != null){
serverProcess.Kill();
serverProcess.WaitForExit();
serverProcess.Dispose();
try{
serverProcess.Kill();
serverProcess.WaitForExit();
serverProcess.Dispose();
}catch(Exception e){
Debug.Write("Dispose" + e.ToString());
}
}
}

14 changes: 11 additions & 3 deletions MultilineGreyText/StatusBar.cs
Original file line number Diff line number Diff line change
@@ -15,19 +15,27 @@ internal class StatusBar{
Brush whiteBrush;
Brush errorBrush;
Brush transparentBrush;
bool isInitialized = false;

public StatusBar(){
stack = new StackPanel();
stack.Width = 75.0;
stack.Orientation = Orientation.Horizontal;
ShowDefaultStatusBar();
}

public bool IsInitialized(){
return isInitialized;
}

public void InitStatusBar(){
isInitialized = true;
panel = VisualTreeUtils.FindChild(Application.Current.MainWindow, childName: "StatusBarPanel") as Panel;
whiteBrush = new SolidColorBrush(Colors.White);
errorBrush = new SolidColorBrush(Colors.Red);
transparentBrush = new SolidColorBrush(Colors.Transparent);
panel.Children.Add(stack);
ShowDefaultStatusBar();
panel.Children.Insert(3, stack);
}

public void ShowDefaultStatusBar(){
stack.Children.Clear();
stack.Background = transparentBrush;
Loading