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

Fix some edits not being sent to LangServ #3186

Merged
merged 30 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ca5d5a8
add Scala test to verify applyEdit behavior in Engine
akavel Dec 8, 2021
11f2eb7
reorder ParsedSourceFile::serialize to ease understanding
akavel Dec 8, 2021
45c98f6
DEBUG tweak editions for debugging
akavel Dec 8, 2021
593c38e
DEBUG set stdlib to 0.0.0-SNAPSHOT
akavel Dec 8, 2021
4e6d742
DEBUG enable debug logging in rust file
akavel Dec 8, 2021
e238d28
DEBUG add some debugging in rust
akavel Dec 8, 2021
d9c444d
DEBUG add some debugging in scala
akavel Dec 8, 2021
f0cbff9
DEBUG try changing ensoVersion in scala to known by IDE
akavel Dec 8, 2021
3885523
DEBUG rebuild stdlib with different version
akavel Dec 8, 2021
5c64b96
DEBUG try bringing back default versions in build.sbt
akavel Dec 9, 2021
e5b0383
DEBUG try bringing back rebuilt SNAPSHOT stdlib
akavel Dec 9, 2021
16f749f
DEBUG dump digest & rope contents in LangServer
akavel Dec 9, 2021
3b83b74
DEBUG WIP
akavel Dec 13, 2021
b8eeef3
WIP subscribe synchronously before adding import
akavel Dec 13, 2021
f144db4
CLEANUP redundant DEBUG
akavel Dec 13, 2021
114d8ac
DEBUG further different digest error
akavel Dec 13, 2021
ac32aa9
DEBUG missing text insertion
akavel Dec 13, 2021
595012e
add test for line insertion edit
akavel Dec 13, 2021
5a03935
fix to not lose text insertions
akavel Dec 13, 2021
166e5b5
CLEANUP DEBUGs
akavel Dec 13, 2021
5cb3c96
CLEANUP rm huge, unreadable, unnecessary test in scala
akavel Dec 13, 2021
a23ab26
CLEANUP delete unclear comment about METADATA_TAG
akavel Dec 13, 2021
169fb01
rename test to avoid confusing double negation
akavel Dec 13, 2021
89a7009
(cargo fmt)
akavel Dec 13, 2021
198723f
Merge remote-tracking branch 'origin/develop' into wip/akavel/langser…
akavel Dec 13, 2021
d6e783f
add changelog entry
akavel Dec 13, 2021
a2cfbab
tweak changelog entry
akavel Dec 13, 2021
c23f7c3
tweak changelog entry
akavel Dec 13, 2021
ddbac61
review: improve changelog wording for users
akavel Dec 13, 2021
fbb812a
review: improve comment above Module::runner
akavel Dec 13, 2021
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
4 changes: 4 additions & 0 deletions app/gui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
- [Fixed broken node whose expression contains non-ASCII characters.][3166]
- [Fixed developer console warnings about views being created but not
registered.][3181]
- [Fixed "Invalid version" error during sending text change to Language
Server.][3186] The error happened during project opening and after new node
creation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the first place, I would say that an error in the console is fixed, because the user will notice rather log in the console than the error in Language Server communication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ thanks! done


[3153]: https://github.com/enso-org/enso/pull/3153
[3166]: https://github.com/enso-org/enso/pull/3166
[3181]: https://github.com/enso-org/enso/pull/3181
[3186]: https://github.com/enso-org/enso/pull/3186

# Enso 2.0.0-alpha.18 (2021-10-12)

Expand Down
5 changes: 3 additions & 2 deletions app/gui/language/parser/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,14 @@ fn to_json_single_line(val: &impl Serialize) -> std::result::Result<String, serd
impl<M: Metadata> ParsedSourceFile<M> {
/// Serialize to the SourceFile structure,
pub fn serialize(&self) -> std::result::Result<SourceFile, serde_json::Error> {
let code = self.ast.repr();
let before_tag = "\n".repeat(NEWLINES_BEFORE_TAG);
let before_idmap = "\n";
let before_metadata = "\n";
let code = self.ast.repr();
let json_id_map = JsonIdMap::from_id_map(&self.ast.id_map(), &code);
let id_map = to_json_single_line(&json_id_map)?;
let before_metadata = "\n";
let metadata = to_json_single_line(&self.metadata)?;

let id_map_start = code.len() + before_tag.len() + METADATA_TAG.len() + before_idmap.len();
let id_map_start_bytes = Bytes::from(id_map_start);
let metadata_start = id_map_start + id_map.len() + before_metadata.len();
Expand Down
60 changes: 41 additions & 19 deletions app/gui/src/model/module/synchronized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,29 +256,32 @@ impl API for Module {
// === Synchronizing Language Server ===

impl Module {
/// The asynchronous task scheduled during struct creation which listens for all module changes
/// and send proper updates to Language Server.
async fn runner(
/// Returns the asynchronous task scheduled during struct creation which listens for all module
/// changes and send proper updates to Language Server.
akavel marked this conversation as resolved.
Show resolved Hide resolved
fn runner(
self: Rc<Self>,
initial_ls_content: ContentSummary,
first_invalidation: impl Future<Output = FallibleResult<ParsedContentSummary>>,
) {
let first_invalidation = first_invalidation.await;
let mut ls_content = self.new_ls_content_info(initial_ls_content, first_invalidation);
) -> impl Future<Output = ()> {
let mut subscriber = self.model.subscribe();
let weak = Rc::downgrade(&self);
drop(self);

loop {
let notification = subscriber.next().await;
let this = weak.upgrade();
match (notification, this) {
(Some(notification), Some(this)) => {
debug!(this.logger, "Processing a notification: {notification:?}");
let result = this.handle_notification(&ls_content, notification).await;
ls_content = this.new_ls_content_info(ls_content.summary().clone(), result)

async move {
let first_invalidation = first_invalidation.await;
let mut ls_content = self.new_ls_content_info(initial_ls_content, first_invalidation);
let weak = Rc::downgrade(&self);
drop(self);

loop {
let notification = subscriber.next().await;
let this = weak.upgrade();
match (notification, this) {
(Some(notification), Some(this)) => {
debug!(this.logger, "Processing a notification: {notification:?}");
let result = this.handle_notification(&ls_content, notification).await;
ls_content = this.new_ls_content_info(ls_content.summary().clone(), result)
}
_ => break,
}
_ => break,
}
}
}
Expand Down Expand Up @@ -359,7 +362,7 @@ impl Module {
debug_assert_eq!(start.column, 0.column());

let edit = TextEdit::from_prefix_postfix_differences(&source, &target);
(edit.range.start != edit.range.end)
(edit.range.start != edit.range.end || !edit.text.is_empty())
.as_some_from(|| edit.move_by_lines(start.line.as_usize()))
}

Expand Down Expand Up @@ -716,4 +719,23 @@ pub mod test {
};
Runner::run(test);
}

#[test]
fn handle_insertion_edits_bug180558676() {
let source = Text::from("from Standard.Base import all\n\nmain =\n operator1 = 0.up_to 100 . to_vector . map .noise\n operator1.sort\n");
let target = Text::from("from Standard.Base import all\nimport Standard.Visualization\n\nmain =\n operator1 = 0.up_to 100 . to_vector . map .noise\n operator1.sort\n");
let edit = Module::edit_for_snipped(
&Location { line: 0.into(), column: 0.into() },
source,
target,
);
let expected = Some(TextEdit {
range: TextRange {
start: Position { line: 1, character: 0 },
end: Position { line: 1, character: 0 },
},
text: "import Standard.Visualization\n".to_string(),
});
assert_eq!(edit, expected);
}
}