-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Left shift fix 2299 #2300
Merged
Merged
Left shift fix 2299 #2300
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0591025
Fix tokenizeKeySequence to allow left shift operator in keysPressed.
9ccad64
Tests for #2299 and other left and right shift operations.
c6dc6db
Fix #2299 left shift operator off by one bug
19e9d7f
Merge branch 'master' into left-shift-fix-2299
jessewmc ed32909
Fix tokenizeKeySequence bug introduced by handling left shift.
e2624c0
Make rawTokenize clearer.
c9b877c
Merge branch 'master' into left-shift-fix-2299
jpoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getAndUpdateModeHandler } from '../../extension'; | ||
import { ModeHandler } from '../../src/mode/modeHandler'; | ||
import { getTestingFunctions } from '../testSimplifier'; | ||
import { cleanUpWorkspace, setupWorkspace } from '../testUtils'; | ||
|
||
suite('shift operator', () => { | ||
let modeHandler: ModeHandler; | ||
|
||
let { newTest, newTestOnly } = getTestingFunctions(); | ||
|
||
setup(async () => { | ||
await setupWorkspace(); | ||
modeHandler = await getAndUpdateModeHandler(); | ||
}); | ||
|
||
teardown(cleanUpWorkspace); | ||
|
||
newTest({ | ||
title: 'basic shift left test', | ||
start: [' |zxcv', ' zxcv', ' zxcv'], | ||
keysPressed: '<<', | ||
end: ['|zxcv', ' zxcv', ' zxcv'], | ||
}); | ||
|
||
newTest({ | ||
title: 'shift left goto end test', | ||
start: [' |zxcv', ' zxcv', ' zxcv'], | ||
keysPressed: '<G', | ||
end: ['|zxcv', 'zxcv', 'zxcv'], | ||
}); | ||
|
||
newTest({ | ||
title: 'shift left goto line test', | ||
start: [' |zxcv', ' zxcv', ' zxcv'], | ||
keysPressed: '<2G', | ||
end: ['|zxcv', 'zxcv', ' zxcv'], | ||
}); | ||
|
||
newTest({ | ||
title: 'shift right goto end test', | ||
start: ['|zxcv', 'zxcv', 'zxcv'], | ||
keysPressed: '>G', | ||
end: [' |zxcv', ' zxcv', ' zxcv'], | ||
}); | ||
|
||
newTest({ | ||
title: 'shift right goto line test', | ||
start: ['|zxcv', 'zxcv', 'zxcv'], | ||
keysPressed: '>2G', | ||
end: [' |zxcv', ' zxcv', 'zxcv'], | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried walking through this a couple of times, it's probably cause it's the end of the day, but I can't grok this code.
The code might be simpler if instead we walk the string, if we see
<
, find the matching>
. If there's no matching<
, then it's a left shift.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what I'm doing is sort of the opposite, I'm looking for another
<
following a<
, and then working back instead of looking ahead.If I see a second
<
(i.e.isBracketedKey
is already truthy when I hit a<
) I know whatever was previous was a left shift and subsequent literal character inputs, so I take the currently builtkey
and tokenize it one character per token.After the tokenizing loop has run, if
isBracketedKey
is truthy I know we also saw an unclosed<
so again I tokenize the currently builtkey
as one character per token.I don't mind looking ahead for closing
>
instead if you still prefer that. I didn't do that because it's a bit more complicated in the case ofkeysPressed
like<<<ESC>
where I would have to start counting open<
s and looking for matches or recursing which seemed overcomplicated for a convenience test helper function. That would be starting to get into serious parsing territory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although now that I've explained this I've found a bug, I will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the explanation.