Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/codegen/codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ class Codegen {
case CodegenLanguage.kotlinOkHttp:
return KotlinOkHttpCodeGen().getCode(rM);
case CodegenLanguage.pythonHttpClient:
return PythonHttpClientCodeGen()
.getCode(rM, boundary: boundary ?? getNewUuid());
return PythonHttpClientCodeGen().getCode(
rM,
boundary: boundary ?? getNewUuid(),
);
case CodegenLanguage.pythonRequests:
return PythonRequestsCodeGen().getCode(rM, boundary: boundary);
case CodegenLanguage.rubyFaraday:
Expand Down Expand Up @@ -121,5 +123,6 @@ class Codegen {
case CodegenLanguage.swiftUrlSession:
return SwiftURLSessionCodeGen().getCode(rM);
}
return null;
}
}
18 changes: 17 additions & 1 deletion lib/providers/terminal_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,30 @@ class TerminalController extends StateNotifier<TerminalState> {
TerminalController() : super(TerminalState(entries: <TerminalEntry>[]));

static const _uuid = Uuid();
static const int _maxEntries = 1000;

String _newId() => _uuid.v4();

void clear() {
state = TerminalState(entries: <TerminalEntry>[]);
}

// String append(TerminalEntry entry) {
// final list = [entry, ...state.entries];
// state = TerminalState(entries: list);
// return entry.id;
// }

String append(TerminalEntry entry) {
final list = [entry, ...state.entries];
final currentEntries = state.entries;

final List<TerminalEntry> list;
if (currentEntries.length >= _maxEntries) {
list = [entry, ...currentEntries.take(_maxEntries - 1)];
} else {
list = [entry, ...currentEntries];
}

state = TerminalState(entries: list);
return entry.id;
}
Expand Down Expand Up @@ -221,5 +236,6 @@ class TerminalController extends StateNotifier<TerminalState> {
final s = e.system!;
return s.message;
}
return null;
}
}
Loading