Add regex mode for word selection definition#593
Add regex mode for word selection definition#593eyupcanakman wants to merge 1 commit intognachman:masterfrom
Conversation
|
This is the problem smart selection is meant to address. I know smart selection is not a great replacement for word selection, and quad-click is inconvenient, so there is definitely room for improvement but I think as written this would break too many workflows. Can you provide more details on your thinking and how you would use this? |
|
@gnachman I understand the concern. I frequently need to copy full URLs from logs to a browser, and smart selection or quad-click feels too slow for this. To avoid breaking existing workflows, would you accept this as an opt-in toggle in Preferences > Advanced? This keeps the default unchanged but solves the issue for users like me who need it. Let me know and I will update the PR. |
|
I think a better solution would be to extend "characters considered part of a word for selection" to be a regular expression. Then you could put There would need to be two modes to switch between "list of characters" and "regex", although in the implementation they could both be implemented as regular expressions. |
|
That makes a lot of sense. I will work on implementing this approach and update the PR. |
50b7265 to
8d4dc74
Compare
|
@gnachman Implemented your suggestion. Word selection now has List (default) and Regex modes. |
|
This ended up being pretty complex. Committed as 54bd855 |
|
Got it, thanks. I'll check master to see how you implemented it. |
Summary
List(default) andRegex.Listmode and allow advanced users to opt into regex-based word selection.Regexmode, select the regex match containing the click location, and fall back to classic list-based selection when there is no valid containing match.Changes
sources/iTermPreferences.hiTermWordSelectionDefinitionMode.sources/iTermPreferences.msources/GeneralPreferencesViewController.mList/Regexpopup next to "Characters considered part of a word".sources/iTermTextExtractor.miTerm2XCTests/iTermTextExtractorTest.mTest
xcodebuild build -project iTerm2.xcodeproj -scheme iTerm2 -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= ENABLE_DEBUG_DYLIB=NOBUILD SUCCEEDEDxcodebuild test -project iTerm2.xcodeproj -scheme iTerm2Tests -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= ENABLE_DEBUG_DYLIB=NO -only-testing:iTerm2XCTests/iTermTextExtractorTestiTerm2XCTests/iTermRuleTest.mon this checkout.