MCPcopy
hub / github.com/philc/vimium / getDirection

Method getDirection

content_scripts/mode_visual.js:146–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 // NOTE(smblott). This could be better, see: https://dom.spec.whatwg.org/#interface-range
145 // (however, that probably wouldn't work for inputs).
146 getDirection() {
147 // Try to move the selection forward or backward, check whether it got bigger or smaller (then
148 // restore it).
149 for (const direction of [forward, backward]) {
150 const change = this.extendByOneCharacter(direction);
151 if (change) {
152 this.extendByOneCharacter(this.opposite[direction]);
153 if (change > 0) {
154 return direction;
155 } else {
156 return this.opposite[direction];
157 }
158 }
159 }
160 return forward;
161 }
162
163 collapseSelectionToAnchor() {
164 if (this.selection.toString().length == 0) return;

Callers 8

reverseSelectionMethod · 0.95
selectLineMethod · 0.95
scrollIntoViewMethod · 0.95
commandHandlerMethod · 0.80
extendSelectionMethod · 0.80

Calls 1

extendByOneCharacterMethod · 0.95

Tested by

no test coverage detected