diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index 9a0696c6c53..2a0d500986a 100644 --- a/crates/ide/src/typing/on_enter.rs +++ b/crates/ide/src/typing/on_enter.rs @@ -1,14 +1,8 @@ //! Handles the `Enter` key press. At the momently, this only continues //! comments, but should handle indent some time in the future as well. -use std::sync::Arc; - +use ide_db::base_db::{FilePosition, SourceDatabase}; use ide_db::RootDatabase; -use ide_db::{ - base_db::{FilePosition, SourceDatabase}, - line_index::LineIndex, - LineIndexDatabase, -}; use syntax::{ algo::find_node_at_offset, ast::{self, edit::IndentLevel, AstToken}, @@ -55,7 +49,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option Option { +fn on_enter_in_block(block: ast::BlockExpr, position: FilePosition) -> Option { let contents = block_contents(&block)?; - let line_index: Arc = db.line_index(position.file_id); - let (open, close) = (block.l_curly_token()?, block.r_curly_token()?); - let start = line_index.line_col(open.text_range().start()).line; - let end = line_index.line_col(close.text_range().end()).line; - if start != end { + if block.syntax().text().contains_char('\n') { return None; }