diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2c296..3124065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog -## [1.8.0] +## [1.8.1] 2020-04-19 +* Fix searches not wrapping around to the top of the file (stef-levesque#68) + +## [1.8.0] 2020-04-18 * Add support for 64-bit integers (thanks @jpihl) * Add `Copy as Golang` and `Copy as String Literal` * Fixed `toggleEndian` (stef-levesque#54) @@ -106,6 +109,7 @@ * Display a specified file in hexadecimal +[1.8.1]: https://github.com/iliazeus/vscode-hexdump/compare/1b2f1ca797c2275e45f3b6c539e9325b191e48e0...7e5f5fef396c21cb80d5bc3b123272fb124d95f1 [1.8.0]: https://github.com/iliazeus/vscode-hexdump/compare/8544cbd4728b01f91a6495507ba986afd0daf366...d3980d68090c78a05843316ea55e3e03178d12e2 [1.7.2]: https://github.com/iliazeus/vscode-hexdump/compare/30b5275c501e5fcc46004ea31bbb0e5e2a25c38f...00bfca333a5e16602131de78d3590d09ff6421a5 [1.7.1]: https://github.com/iliazeus/vscode-hexdump/compare/83ad82e8503774b61c5118b254fb4fd1b849144f...3306e974af00e954a0d5286c36d26b9f95ae250a diff --git a/src/extension.ts b/src/extension.ts index 38de13d..817fe6b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -358,11 +358,16 @@ export function activate(context: vscode.ExtensionContext) { const array = await getContents(d.uri); - var index = Buffer.from(array).indexOf(value, offset, charEncoding); + let index = Buffer.from(array).indexOf(value, offset, charEncoding); - if (index == -1) { - vscode.window.setStatusBarMessage('string not found', 3000); - return; + if (index === -1) { + // wrap the search around from the top + index = Buffer.from(array).indexOf(value, 0, charEncoding); + + if (index === -1) { + vscode.window.setStatusBarMessage('string not found', 3000); + return; + } } // Translate one to be in the middle of the byte @@ -404,11 +409,16 @@ export function activate(context: vscode.ExtensionContext) { searchBuf.writeUInt8(parseInt(byte, 16), i); } - const index = Buffer.from(getContents(d.uri)).indexOf(searchBuf, offset); + let index = Buffer.from(getContents(d.uri)).indexOf(searchBuf, offset); - if (index == -1) { - vscode.window.setStatusBarMessage('HEX string not found', 3000); - return; + if (index === -1) { + // wrap the search around from the top + index = Buffer.from(getContents(d.uri)).indexOf(searchBuf, 0); + + if (index === -1) { + vscode.window.setStatusBarMessage('HEX string not found', 3000); + return; + } } // Translate one to be in the middle of the byte