vim-prose 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -831,6 +831,9 @@ export function handleKeyDown(view, event, vimState, commands) {
|
|
|
831
831
|
else {
|
|
832
832
|
// Switch from visual-line to characterwise visual
|
|
833
833
|
vimState.mode = 'visual';
|
|
834
|
+
const tr = state.tr;
|
|
835
|
+
updateVisualSelection(state, tr, vimState, pos);
|
|
836
|
+
view.dispatch(tr);
|
|
834
837
|
}
|
|
835
838
|
clearPendingState(vimState);
|
|
836
839
|
return true;
|
|
@@ -136,6 +136,18 @@ export function createVimPlugin(commands) {
|
|
|
136
136
|
decorations.push(Decoration.inline(state.selection.from, state.selection.to, {
|
|
137
137
|
class: 'vim-visual-selection',
|
|
138
138
|
}));
|
|
139
|
+
// Inline decorations won't visibly highlight empty textblocks, so
|
|
140
|
+
// add a block-level decoration for selected empty lines.
|
|
141
|
+
state.doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
|
|
142
|
+
if (node.isTextblock &&
|
|
143
|
+
node.content.size === 0 &&
|
|
144
|
+
state.selection.from <= pos + node.nodeSize &&
|
|
145
|
+
state.selection.to >= pos) {
|
|
146
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
147
|
+
class: 'vim-visual-selection-line',
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
139
151
|
}
|
|
140
152
|
}
|
|
141
153
|
// Search match highlights (visible in all modes)
|
|
@@ -139,17 +139,20 @@ export function findAllMatches(state, term, wholeWord = false) {
|
|
|
139
139
|
if (!term)
|
|
140
140
|
return [];
|
|
141
141
|
const positions = [];
|
|
142
|
+
const searchTerm = term.toLocaleLowerCase();
|
|
142
143
|
state.doc.descendants((node, pos) => {
|
|
143
144
|
if (node.isText && node.text) {
|
|
145
|
+
const text = node.text;
|
|
146
|
+
const textForSearch = text.toLocaleLowerCase();
|
|
144
147
|
let idx = 0;
|
|
145
148
|
while (true) {
|
|
146
|
-
const found =
|
|
149
|
+
const found = textForSearch.indexOf(searchTerm, idx);
|
|
147
150
|
if (found === -1)
|
|
148
151
|
break;
|
|
149
152
|
if (wholeWord) {
|
|
150
|
-
const before = found > 0 ?
|
|
151
|
-
const after = found + term.length <
|
|
152
|
-
?
|
|
153
|
+
const before = found > 0 ? text[found - 1] : '';
|
|
154
|
+
const after = found + term.length < text.length
|
|
155
|
+
? text[found + term.length]
|
|
153
156
|
: '';
|
|
154
157
|
if ((before && isWordChar(before)) || (after && isWordChar(after))) {
|
|
155
158
|
idx = found + 1;
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
background: rgba(59, 130, 246, 0.3);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/* Empty selected lines need a node-level highlight. */
|
|
34
|
+
.vim-visual-selection-line {
|
|
35
|
+
background: rgba(59, 130, 246, 0.3);
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
/* Suppress native selection in visual modes (we use decorations instead) */
|
|
34
39
|
.vim-mode-visual ::selection,
|
|
35
40
|
.vim-mode-visual-line ::selection {
|