clide:// deep link handler — open files at a line (T-56)
clide://open?path=&line= translates (in parseArgv) to editor.open, so an OS scheme invocation routes through the existing CLI→IPC path into the running window — single-instance for free, no new code path. Registered the scheme: linux/clide.desktop MimeType x-scheme-handler/clide (Exec already passes %U) and macOS Info.plist CFBundleURLTypes. Parser validates the action/path/line. Linux works end to end (the OS passes the URL as argv). macOS URL DELIVERY (the AppDelegate openURLs callback → forward into this path) is a follow-up — the scheme is registered, but the native hook needs a real macOS machine to verify, so it's not shipped blind. Also drops a stray import in clide_markdown_test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -149,4 +149,38 @@ void main() {
|
||||
expect(r.args['positional'], ['README.md']);
|
||||
});
|
||||
});
|
||||
|
||||
group('parseArgv — clide:// deep links (T-56)', () {
|
||||
test('clide://open?path= maps to editor.open', () {
|
||||
final req = _expectOk(parseArgv(['clide://open?path=/repo/x.md'], requestId: '1'));
|
||||
expect(req.cmd, 'editor.open');
|
||||
expect(req.args['positional'], ['/repo/x.md']);
|
||||
});
|
||||
|
||||
test('a &line= becomes the second positional', () {
|
||||
final req = _expectOk(parseArgv(['clide://open?path=/repo/x.md&line=42'], requestId: '2'));
|
||||
expect(req.cmd, 'editor.open');
|
||||
expect(req.args['positional'], ['/repo/x.md', '42']);
|
||||
});
|
||||
|
||||
test('an encoded path is decoded', () {
|
||||
final req = _expectOk(parseArgv(['clide://open?path=/a%20b/c.dart'], requestId: '3'));
|
||||
expect(req.args['positional'], ['/a b/c.dart']);
|
||||
});
|
||||
|
||||
test('missing path errors', () {
|
||||
final err = _expectErr(parseArgv(['clide://open'], requestId: '4'));
|
||||
expect(err.error?.message, contains('requires a ?path'));
|
||||
});
|
||||
|
||||
test('a non-positive or non-numeric line errors', () {
|
||||
expect(_expectErr(parseArgv(['clide://open?path=/x&line=0'], requestId: '5')).error?.message, contains('positive integer'));
|
||||
expect(_expectErr(parseArgv(['clide://open?path=/x&line=abc'], requestId: '6')).error?.message, contains('positive integer'));
|
||||
});
|
||||
|
||||
test('an unknown action errors', () {
|
||||
final err = _expectErr(parseArgv(['clide://frobnicate?x=1'], requestId: '7'));
|
||||
expect(err.error?.message, contains('unknown clide:// action'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
library;
|
||||
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../helpers/kernel_fixture.dart';
|
||||
|
||||
Reference in New Issue
Block a user