Skip to content

Commit

Permalink
another attempt to improve lsp ux
Browse files Browse the repository at this point in the history
  • Loading branch information
Freaxed committed Jan 22, 2025
1 parent 610017c commit 24e3009
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/lsp-client/LSPEditorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ LSPEditorWrapper::didClose()
if (!IsInitialized())
return;

flushChanges();

if (fEditor) {
_RemoveAllDiagnostics();
_RemoveAllDocumentLinks();
Expand Down Expand Up @@ -265,6 +267,8 @@ LSPEditorWrapper::Format()
if (!IsInitialized() || !fEditor)
return;

flushChanges();

// format a range or format the whole doc?
Sci_Position s_start = fEditor->SendMessage(SCI_GETSELECTIONSTART, 0, 0);
Sci_Position s_end = fEditor->SendMessage(SCI_GETSELECTIONEND, 0, 0);
Expand All @@ -285,6 +289,8 @@ LSPEditorWrapper::GoTo(LSPEditorWrapper::GoToType type)
if (!IsInitialized()|| !fEditor || !IsStatusValid())
return;

flushChanges();

Position position;
GetCurrentLSPPosition(&position);

Expand All @@ -308,6 +314,8 @@ LSPEditorWrapper::Rename(std::string newName)
if (!IsInitialized()|| !fEditor || !IsStatusValid())
return;

flushChanges();

Position position;
GetCurrentLSPPosition(&position);
fLSPProjectWrapper->Rename(this, position, newName);
Expand Down Expand Up @@ -392,6 +400,8 @@ LSPEditorWrapper::SelectedCompletion(const char* text)
if (!IsInitialized() || !fEditor)
return;

flushChanges();

if (fCurrentCompletion.items.size() > 0) {
for (auto& item : fCurrentCompletion.items) {
if (item.label.compare(std::string(text)) == 0) {
Expand Down Expand Up @@ -455,6 +465,8 @@ LSPEditorWrapper::StartCompletion()
if (!IsInitialized() || !fEditor || !IsStatusValid())
return;

flushChanges();

// let's check if a completion is ongoing
if (fCurrentCompletion.items.size() > 0) {
// let's close the current Scintilla listbox
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
namespace Sci = Scintilla;
using namespace Sci::Properties;

const int kIdleTimeout = 500000; //1/2sec
const int kIdleTimeout = 250000; //1/4sec

// Differentiate unset parameters from 0 ones
// in scintilla messages
Expand Down

0 comments on commit 24e3009

Please sign in to comment.