From 89f015ead9ed947d81eecb6e7533f0b8e5f4ed54 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 12 Apr 2021 21:41:44 +0200 Subject: Simplify multiline check --- crates/ide/src/typing/on_enter.rs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index 9a0696c6c..2a0d50098 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; } -- cgit v1.2.3