@noldova/terminal 0.0.11 → 0.0.13

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.
@@ -57,6 +57,7 @@ export class TerminalSession {
57
57
  text;
58
58
  changes = new ChangeSignal();
59
59
  hasIntegration;
60
+ hasPrompted = false;
60
61
  promptLine = null;
61
62
  constructor(sessionId, shellId, size, process, nonce, windowsPty, historyPaths, storedLimit, listener, textLimit, shellKind, marksInput) {
62
63
  this.sessionId = sessionId;
@@ -109,6 +110,9 @@ export class TerminalSession {
109
110
  get shellTemporaryFolder() {
110
111
  return this.commands.temporaryFolder;
111
112
  }
113
+ get shellHome() {
114
+ return this.commands.home;
115
+ }
112
116
  get shellModulePath() {
113
117
  return this.commands.modulePath;
114
118
  }
@@ -149,6 +153,11 @@ export class TerminalSession {
149
153
  }
150
154
  this.terminal.write(data);
151
155
  }
156
+ sendFolder(keys, folder) {
157
+ this.options.cancel();
158
+ this.beforeInput();
159
+ this.terminal.write(`${keys}${Buffer.from(folder).toString(Resources.folderEncoding)}${Resources.enterKey}`);
160
+ }
152
161
  typeLine(text) {
153
162
  const line = new TypedLine(this.text.endOffset, text);
154
163
  this.typedLines.add(line);
@@ -233,6 +242,7 @@ export class TerminalSession {
233
242
  this.terminal.pause();
234
243
  this.scanner = Object.isNull(nonce) ? null : new MarkScanner(nonce);
235
244
  this.hasIntegration = !Object.isNull(nonce);
245
+ this.hasPrompted = false;
236
246
  this.commands = this.trackCommands();
237
247
  this.options.reset();
238
248
  this.hasAnsweredOptions = false;
@@ -251,7 +261,7 @@ export class TerminalSession {
251
261
  this.insert(TerminalSession.toNote(text));
252
262
  }
253
263
  toSummary(folder, isAgentTerminal, isPanelTerminal, owner, opensTab, name, shellName) {
254
- return new TerminalSummary(this.sessionId, this.shellId, folder, this.mirror.title, this.exit, isAgentTerminal, isPanelTerminal, owner, opensTab, name, shellName, this.shellKind);
264
+ return new TerminalSummary(this.sessionId, this.shellId, folder, this.mirror.title, this.exit, isAgentTerminal, isPanelTerminal, owner, opensTab, name, shellName, this.shellKind, this.hasIntegration, this.hasPrompted);
255
265
  }
256
266
  disposeAsync() {
257
267
  this.disposal.abort();
@@ -353,8 +363,10 @@ export class TerminalSession {
353
363
  const exitCode = this.commands.lastCommand?.exitCode ?? null;
354
364
  this.listener.onCommandEnded(new TerminalCommandEnded(this.sessionId, !Object.isNull(exitCode) && exitCode >= ProtocolResources.minimumExitCode && exitCode <= ProtocolResources.maximumExitCode ? exitCode : null));
355
365
  }
356
- else if (mark.kind === MarkKind.PromptStart)
366
+ else if (mark.kind === MarkKind.PromptStart) {
367
+ this.hasPrompted = true;
357
368
  this.listener.onPromptStarted(new TerminalReference(this.sessionId));
369
+ }
358
370
  const cwd = this.commands.cwd;
359
371
  if (Object.isNull(cwd) || cwd === this.reportedCwd || cwd.trim().length === 0 || cwd.length > ProtocolResources.maximumPathLength)
360
372
  return;
@@ -388,7 +400,7 @@ export class TerminalSession {
388
400
  if (this.terminal === terminal)
389
401
  this.wakeup?.beforeInput();
390
402
  }
391
- }, !Object.isNull(this.windowsPty));
403
+ }, !Object.isNull(this.windowsPty), !Resources.resizeQuietShellIds.includes(this.shellId));
392
404
  return terminal;
393
405
  }
394
406
  end(exitCode) {
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import path from "node:path";
9
+ import { ProgramCall } from "../models/program-call.js";
10
+ import { Resources } from "../resources.js";
11
+ import { PosixShellAdapter } from "./posix-shell-adapter.js";
12
+ export class WslShellAdapter {
13
+ ignoresCase = false;
14
+ separator = Resources.posixSeparator;
15
+ takesBareNames = false;
16
+ optionsKeys = null;
17
+ folderKeys = null;
18
+ looksUpMissing = false;
19
+ takesWindowsNames = false;
20
+ posix = new PosixShellAdapter(false, null, null, false);
21
+ launcher;
22
+ distribution;
23
+ share;
24
+ constructor(launcher, distribution) {
25
+ this.launcher = launcher;
26
+ this.distribution = distribution;
27
+ this.share = `${Resources.wslShareRoot}${distribution}`;
28
+ }
29
+ readWords(line) {
30
+ return this.posix.readWords(line);
31
+ }
32
+ writeWord(value, quote, closesQuote, escapesWildcards, keepsHome) {
33
+ return this.posix.writeWord(value, quote, closesQuote, escapesWildcards, keepsHome);
34
+ }
35
+ escapesWildcards() {
36
+ return false;
37
+ }
38
+ expandsHome(startsQuoted) {
39
+ return this.posix.expandsHome(startsQuoted);
40
+ }
41
+ listBuiltins(shellNames, shellBuiltins) {
42
+ return this.posix.listBuiltins(shellNames, shellBuiltins);
43
+ }
44
+ toLocalPath(value) {
45
+ if (!path.posix.isAbsolute(value))
46
+ return value;
47
+ return value.includes(Resources.windowsSeparator) ? null : `${this.share}${value.replaceAll(Resources.posixSeparator, Resources.windowsSeparator)}`;
48
+ }
49
+ readSearchFolders(value) {
50
+ return value.split(path.posix.delimiter).filter(t => path.posix.isAbsolute(t) && !t.includes(Resources.windowsSeparator)).map(t => `${this.share}${t.replaceAll(Resources.posixSeparator, Resources.windowsSeparator)}`);
51
+ }
52
+ toProgramCall(file, args) {
53
+ return new ProgramCall(this.launcher, [Resources.wslDistributionArgument, this.distribution, Resources.wslExecArgument, ...[file, ...args].map(t => this.toShellPath(t))]);
54
+ }
55
+ toShellPath(value) {
56
+ if (!value.toLowerCase().startsWith(`${this.share.toLowerCase()}${Resources.windowsSeparator}`))
57
+ return value;
58
+ return value.slice(this.share.length).replaceAll(Resources.windowsSeparator, Resources.posixSeparator);
59
+ }
60
+ }