Repository navigation
Migration to Charm V2 libs - #5
Merged
Merged
Conversation
…d input; robust test slicing
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 33 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
render.go:284
- calculateCompletionsOffset can return a negative offset when the completion box is wider than the terminal (e.g., long completion names). That negative value is passed into lipgloss.Margin, which can lead to incorrect layout and may panic depending on lipgloss internals. Clamp the overflow-adjusted offset to >= 0.
offset += m.CompletionsOffset
if offset+lipgloss.Width(completions) > m.width {
offset = m.width - lipgloss.Width(completions) - 2
}
…ed UTF-8 behavior, plus example path fix
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking Changes
github.com/charmbracelet/{bubbletea, bubbles, lipgloss}withcharm.land/{bubbletea, bubbles, lipgloss}/v2.Model.View()now returnstea.View; use the newModel.Render() stringto compose into a larger view.Stylesstruct. Eleven individual public style fields (ValidCommandStyle,MatchHighlightStyle,SelectedRowStyle, etc.) are gone. Customize viabc.SetStyles(styles)/bc.Styles().bc.SetKeyMap(km)/bc.KeyMap().Model.Errprivatized. Usebc.Error().CompletionandArgumentinterfaces unexported. They were never implementable externally (unexported methods); external extension will land via a futureCompletionProviderAPI.ArgumentTypeis now exported (previouslyargumentType). All existing constants (StringArgument, etc.) are unchanged.-1,-?,-éetc. are no longer valid. Use a long or PowerShell flag for non-letter names.SelectedCommandMsgshape unchanged, but the wrapped error is now a typed*ValidationError.HistoryLimit <= 0disables history. Previously undefined.Added
New(commands, width, opts ...Option)with 14With*constructors:WithHistoryLimit,WithHistoryFilePath,WithPlaceholder,WithWidth,WithCompletionRows,WithCompletionsPosition,WithCompletionsOffset,WithIndentCompletions,WithAutotrim,WithScrollbar,WithBorderScroll,WithIcons,WithKeyMap,WithStyles,WithDescriptions.Styles/KeyMapaccessors for grouped configuration.Model.Value()andModel.ValidationError()read-only state accessors for host integration.Model.Error() errorreplaces the oldErrfield; clears on each successful operation.Model.Error() errorreplaces the oldErrfield; clears on each successful operation.*ValidationErrorexposes aValidationErrorKindso hosts can route onerrors.Aswithout parsing error strings. Nine kinds:InvalidCommand,UnknownFlag,MalformedFlag,MissingFlagValue,InvalidArgumentValue,MissingPositionalArgument,UnexpectedArgument,PathNotFound,UnclosedQuote.ShowDescriptionsoption. Hide the description column on completion rows.Enter command...— configurable viaWithPlaceholder/SetPlaceholder.tokenize,validateCommandInput, andgetCompletionswith a seed corpus covering empty input, quote variants, multi-byte runes, emoji, and tabs.gofmt,go vet, race tests, and example build on every PR.Updated
splitInput,containsFlag/containsShortFlag/containsLongFlag, and command/subcommand detection all go through a singletokenize()that understands quotes. The whole parser/completion/validation stack now sees the same parse of any input.lipgloss.Width/ansi.Truncate; CJK, emoji, accented characters, and ANSI-styled content all lay out correctly.🐛) no longer mess up the title column.RenderintoUpdate;Rendercalls are idempotent.New/SetWidthclamp width to ≥ 1,getCompletionsWidthrespects narrow terminals (no more "60-cell completion box in a 20-cell terminal").Command.Validate()now rejects nil pointers, duplicate sibling names, duplicate flag aliases, duplicate positional argument names, theSubCommands + PositionalArgumentscombination, and whitespace in command names.Flag.Validate()rejects---bodied short flags, whitespace in long/PowerShell flag bodies, and invalidArgumentTypevalues.--depth -1and--threshold -0.5now validate forIntArgumentandFloatArgumentflags.-xyzcan be value-taking.Bug Fixes
SetHistoryFilePath(theos.Createresult was never closed).Model.Error().splitPositionArgsAndFlagsdouble-appending the same token when one of multiple flags matched.git commit --amendwith no trailing space).validateCommandInputmodulo panic when terminal width was 0.MalformedFlagerrors being swallowed by the long-flag fallback path.resetModelleaving stalecompletionHolder,showAll,filteredHistory,lastInput, andvalidationErracross submits — caused the "tab on empty → enter → tab again" stale-state bug.SetWidthpropagation to the embeddedtextinput).tea.KeyPressMsg.String()returns"space"in v2, which broke the oldlen(msg.String()) > 1guard.Documentation
View() tea.View, options at construction time, groupedStyles,KeyMapcustomization, history file setup, command validation rules, persistent flag behavior, PowerShell flag constraints, filesystem validation behavior, input parsing rules, concurrency note, intentional non-goals.doc.go.BoolArgumentnow correctly documented as a presence flag (no value follows).Internal
parse.gowith atokenstruct carryingRaw/Unquoted/byte offsets/Quoted/Closedmetadata.history.go.bubblecomplete.goslimmed by ~30%.TestCommandsprivatized (was leaking as public API); example now has its owndemoCommandsfixture.go run ./exampleworks from the repo root.