mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:52:45 +00:00 
			
		
		
		
	TextEditor: Jump to word break when deleting and holding Ctrl modifier
This commit is contained in:
		
							parent
							
								
									107db38a51
								
							
						
					
					
						commit
						a2bbacbfc8
					
				
					 2 changed files with 6 additions and 3 deletions
				
			
		|  | @ -442,8 +442,8 @@ TextPosition TextDocument::first_word_break_before(const TextPosition& position, | ||||||
|     auto is_start_alphanumeric = isalnum(line.codepoints()[target.column() - (start_at_column_before ? 1 : 0)]); |     auto is_start_alphanumeric = isalnum(line.codepoints()[target.column() - (start_at_column_before ? 1 : 0)]); | ||||||
| 
 | 
 | ||||||
|     while (target.column() > 0) { |     while (target.column() > 0) { | ||||||
|         auto next_codepoint = line.codepoints()[target.column() - 1]; |         auto prev_codepoint = line.codepoints()[target.column() - 1]; | ||||||
|         if ((is_start_alphanumeric && !isalnum(next_codepoint)) || (!is_start_alphanumeric && isalnum(next_codepoint))) |         if ((is_start_alphanumeric && !isalnum(prev_codepoint)) || (!is_start_alphanumeric && isalnum(prev_codepoint))) | ||||||
|             break; |             break; | ||||||
|         target.set_column(target.column() - 1); |         target.set_column(target.column() - 1); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -895,7 +895,10 @@ void TextEditor::keydown_event(KeyEvent& event) | ||||||
|         } |         } | ||||||
|         if (m_cursor.column() > 0) { |         if (m_cursor.column() > 0) { | ||||||
|             int erase_count = 1; |             int erase_count = 1; | ||||||
|             if (current_line().first_non_whitespace_column() >= m_cursor.column()) { |             if (event.modifiers() == Mod_Ctrl) { | ||||||
|  |                 auto word_break_pos = document().first_word_break_before(m_cursor, true); | ||||||
|  |                 erase_count = m_cursor.column() - word_break_pos.column(); | ||||||
|  |             } else if (current_line().first_non_whitespace_column() >= m_cursor.column()) { | ||||||
|                 int new_column; |                 int new_column; | ||||||
|                 if (m_cursor.column() % m_soft_tab_width == 0) |                 if (m_cursor.column() % m_soft_tab_width == 0) | ||||||
|                     new_column = m_cursor.column() - m_soft_tab_width; |                     new_column = m_cursor.column() - m_soft_tab_width; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sasan Hezarkhani
						Sasan Hezarkhani