vim-sim 1.0.3 → 1.0.4
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +59 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -634,6 +634,7 @@ declare class CompletionManager {
|
|
|
634
634
|
lineCompletion(buffer: string, cursorLine: number, cursorCol: number): CompletionMatch[];
|
|
635
635
|
/**
|
|
636
636
|
* Start filename completion
|
|
637
|
+
* Note: This is a stub in browser environments. File system access requires Node.js.
|
|
637
638
|
*/
|
|
638
639
|
fileNameCompletion(buffer: string, cursorLine: number, cursorCol: number, currentDir?: string): Promise<CompletionMatch[]>;
|
|
639
640
|
/**
|
|
@@ -655,6 +656,7 @@ declare class CompletionManager {
|
|
|
655
656
|
private extractKeywords;
|
|
656
657
|
/**
|
|
657
658
|
* Get file type information
|
|
659
|
+
* Note: Stub implementation for browser compatibility
|
|
658
660
|
*/
|
|
659
661
|
private getFileTypeInfo;
|
|
660
662
|
/**
|
package/dist/index.js
CHANGED
|
@@ -642,19 +642,19 @@ var FileSystemManager = class _FileSystemManager {
|
|
|
642
642
|
/**
|
|
643
643
|
* Create or open a file with the given path
|
|
644
644
|
*/
|
|
645
|
-
openFile(
|
|
645
|
+
openFile(path, content = "", readonly = false) {
|
|
646
646
|
const newFiles = new Map(this.files);
|
|
647
|
-
if (newFiles.has(
|
|
648
|
-
return new _FileSystemManager(newFiles,
|
|
647
|
+
if (newFiles.has(path)) {
|
|
648
|
+
return new _FileSystemManager(newFiles, path);
|
|
649
649
|
}
|
|
650
650
|
const file = {
|
|
651
|
-
path
|
|
651
|
+
path,
|
|
652
652
|
buffer: new Buffer(content),
|
|
653
653
|
modified: false,
|
|
654
654
|
readonly
|
|
655
655
|
};
|
|
656
|
-
newFiles.set(
|
|
657
|
-
return new _FileSystemManager(newFiles,
|
|
656
|
+
newFiles.set(path, file);
|
|
657
|
+
return new _FileSystemManager(newFiles, path);
|
|
658
658
|
}
|
|
659
659
|
/**
|
|
660
660
|
* Update the buffer content for the current file
|
|
@@ -739,9 +739,9 @@ var FileSystemManager = class _FileSystemManager {
|
|
|
739
739
|
/**
|
|
740
740
|
* Switch to a specific file by path
|
|
741
741
|
*/
|
|
742
|
-
switchToFile(
|
|
743
|
-
if (this.files.has(
|
|
744
|
-
return new _FileSystemManager(this.files,
|
|
742
|
+
switchToFile(path) {
|
|
743
|
+
if (this.files.has(path)) {
|
|
744
|
+
return new _FileSystemManager(this.files, path);
|
|
745
745
|
}
|
|
746
746
|
return this;
|
|
747
747
|
}
|
|
@@ -1304,8 +1304,6 @@ var SpellChecker = class _SpellChecker {
|
|
|
1304
1304
|
};
|
|
1305
1305
|
|
|
1306
1306
|
// src/types/CompletionManager.ts
|
|
1307
|
-
import path from "path";
|
|
1308
|
-
import * as fs from "fs";
|
|
1309
1307
|
var CompletionManager = class _CompletionManager {
|
|
1310
1308
|
state = null;
|
|
1311
1309
|
constructor() {
|
|
@@ -1406,36 +1404,19 @@ var CompletionManager = class _CompletionManager {
|
|
|
1406
1404
|
}
|
|
1407
1405
|
/**
|
|
1408
1406
|
* Start filename completion
|
|
1407
|
+
* Note: This is a stub in browser environments. File system access requires Node.js.
|
|
1409
1408
|
*/
|
|
1410
|
-
async fileNameCompletion(buffer, cursorLine, cursorCol, currentDir
|
|
1409
|
+
async fileNameCompletion(buffer, cursorLine, cursorCol, currentDir) {
|
|
1411
1410
|
const prefix = this.getFilePathPrefix(buffer, cursorLine, cursorCol);
|
|
1412
1411
|
if (prefix.length === 0) return [];
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
}
|
|
1422
|
-
const matches = files.filter((file) => file.startsWith(basename)).map((file) => ({
|
|
1423
|
-
text: path.join(path.dirname(prefix), file),
|
|
1424
|
-
type: "filename" /* FILENAME */,
|
|
1425
|
-
info: this.getFileTypeInfo(path.join(dirname, file))
|
|
1426
|
-
}));
|
|
1427
|
-
this.state = {
|
|
1428
|
-
matches,
|
|
1429
|
-
currentIndex: 0,
|
|
1430
|
-
prefix,
|
|
1431
|
-
type: "filename" /* FILENAME */,
|
|
1432
|
-
isActive: prefix.length > 0
|
|
1433
|
-
// Active if we have a prefix, even if no matches
|
|
1434
|
-
};
|
|
1435
|
-
return matches;
|
|
1436
|
-
} catch (error) {
|
|
1437
|
-
return [];
|
|
1438
|
-
}
|
|
1412
|
+
this.state = {
|
|
1413
|
+
matches: [],
|
|
1414
|
+
currentIndex: 0,
|
|
1415
|
+
prefix,
|
|
1416
|
+
type: "filename" /* FILENAME */,
|
|
1417
|
+
isActive: prefix.length > 0
|
|
1418
|
+
};
|
|
1419
|
+
return [];
|
|
1439
1420
|
}
|
|
1440
1421
|
/**
|
|
1441
1422
|
* Start omni completion - context-aware completion
|
|
@@ -1499,17 +1480,10 @@ var CompletionManager = class _CompletionManager {
|
|
|
1499
1480
|
}
|
|
1500
1481
|
/**
|
|
1501
1482
|
* Get file type information
|
|
1483
|
+
* Note: Stub implementation for browser compatibility
|
|
1502
1484
|
*/
|
|
1503
1485
|
getFileTypeInfo(filepath) {
|
|
1504
|
-
|
|
1505
|
-
const stat = fs.statSync(filepath);
|
|
1506
|
-
if (stat.isDirectory()) return "directory";
|
|
1507
|
-
if (stat.isFile()) return "file";
|
|
1508
|
-
if (stat.isSymbolicLink()) return "symlink";
|
|
1509
|
-
return "unknown";
|
|
1510
|
-
} catch {
|
|
1511
|
-
return "unknown";
|
|
1512
|
-
}
|
|
1486
|
+
return "unknown";
|
|
1513
1487
|
}
|
|
1514
1488
|
/**
|
|
1515
1489
|
* Get completion text to insert (without prefix)
|
|
@@ -2073,6 +2047,29 @@ function handleInsertArrowDown(state) {
|
|
|
2073
2047
|
}
|
|
2074
2048
|
return state;
|
|
2075
2049
|
}
|
|
2050
|
+
function handleInsertDelete(state) {
|
|
2051
|
+
const lines = state.buffer.content.split("\n");
|
|
2052
|
+
const currentLine2 = lines[state.cursor.line] ?? "";
|
|
2053
|
+
if (state.cursor.column < currentLine2.length) {
|
|
2054
|
+
const newLine = currentLine2.slice(0, state.cursor.column) + currentLine2.slice(state.cursor.column + 1);
|
|
2055
|
+
lines[state.cursor.line] = newLine;
|
|
2056
|
+
return {
|
|
2057
|
+
...state,
|
|
2058
|
+
buffer: new Buffer(lines.join("\n")),
|
|
2059
|
+
desiredColumn: null
|
|
2060
|
+
};
|
|
2061
|
+
} else if (state.cursor.line < lines.length - 1) {
|
|
2062
|
+
const nextLine = lines[state.cursor.line + 1] ?? "";
|
|
2063
|
+
lines[state.cursor.line] = currentLine2 + nextLine;
|
|
2064
|
+
lines.splice(state.cursor.line + 1, 1);
|
|
2065
|
+
return {
|
|
2066
|
+
...state,
|
|
2067
|
+
buffer: new Buffer(lines.join("\n")),
|
|
2068
|
+
desiredColumn: null
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
return state;
|
|
2072
|
+
}
|
|
2076
2073
|
function handleInsertCharacter(state, char) {
|
|
2077
2074
|
const lines = state.buffer.content.split("\n");
|
|
2078
2075
|
const currentLine2 = lines[state.cursor.line] ?? "";
|
|
@@ -3449,11 +3446,23 @@ var dd = class extends Command {
|
|
|
3449
3446
|
};
|
|
3450
3447
|
var Delete = class extends Operator {
|
|
3451
3448
|
key = "Delete";
|
|
3449
|
+
// Override Operator defaults - Delete doesn't accept motions/text objects
|
|
3450
|
+
acceptsMotion = false;
|
|
3451
|
+
acceptsTextObject = false;
|
|
3452
3452
|
execute(state, context) {
|
|
3453
3453
|
if (state.selection) {
|
|
3454
3454
|
return deleteRangeWithRegister(state, state.selection, context, false);
|
|
3455
3455
|
}
|
|
3456
|
-
|
|
3456
|
+
const count = context.count ?? 1;
|
|
3457
|
+
return deleteRangeWithRegister(
|
|
3458
|
+
state,
|
|
3459
|
+
{
|
|
3460
|
+
start: state.cursor,
|
|
3461
|
+
end: new Cursor(state.cursor.line, state.cursor.column + count)
|
|
3462
|
+
},
|
|
3463
|
+
context,
|
|
3464
|
+
false
|
|
3465
|
+
);
|
|
3457
3466
|
}
|
|
3458
3467
|
};
|
|
3459
3468
|
|
|
@@ -6628,6 +6637,8 @@ var Session = class _Session {
|
|
|
6628
6637
|
this.state = handleInsertEnter(this.state, this.indentationManager);
|
|
6629
6638
|
} else if (key === "Space") {
|
|
6630
6639
|
this.state = handleInsertSpace(this.state);
|
|
6640
|
+
} else if (key === "Delete") {
|
|
6641
|
+
this.state = handleInsertDelete(this.state);
|
|
6631
6642
|
} else if (key === "ArrowLeft") {
|
|
6632
6643
|
this.state = handleInsertArrowLeft(this.state);
|
|
6633
6644
|
} else if (key === "ArrowRight") {
|