mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:32:44 +00:00 
			
		
		
		
	LibGUI: Make arrow-left/right with selection move cursor to edge of selection
This matches behavior on Linux, macOS, Windows, and it makes it possible to hit ctrl-L arrow-right ctrl-backspace to edit the last component of an URL in browser, or of the current path in File Manager. Also make it so that ctrl-left/right does a word movement that starts at the edge of the selection. This matches Linux and macOS, but not Windows (which instead does a word movement relative to the cursor, not the selection edge).
This commit is contained in:
		
							parent
							
								
									95077f9a5d
								
							
						
					
					
						commit
						397e5766ff
					
				
					 1 changed files with 18 additions and 0 deletions
				
			
		|  | @ -794,6 +794,15 @@ void TextEditor::keydown_event(KeyEvent& event) | |||
|         return; | ||||
|     } | ||||
|     if (event.key() == KeyCode::Key_Left) { | ||||
|         if (!event.shift() && m_selection.is_valid()) { | ||||
|             set_cursor(m_selection.normalized().start()); | ||||
|             m_selection.clear(); | ||||
|             did_update_selection(); | ||||
|             if (!event.ctrl()) { | ||||
|                 update(); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         if (event.ctrl()) { | ||||
|             TextPosition new_cursor; | ||||
|             if (document().has_spans()) { | ||||
|  | @ -836,6 +845,15 @@ void TextEditor::keydown_event(KeyEvent& event) | |||
|         return; | ||||
|     } | ||||
|     if (event.key() == KeyCode::Key_Right) { | ||||
|         if (!event.shift() && m_selection.is_valid()) { | ||||
|             set_cursor(m_selection.normalized().end()); | ||||
|             m_selection.clear(); | ||||
|             did_update_selection(); | ||||
|             if (!event.ctrl()) { | ||||
|                 update(); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         if (event.ctrl()) { | ||||
|             TextPosition new_cursor; | ||||
|             if (document().has_spans()) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nico Weber
						Nico Weber