@@ -107,47 +107,60 @@ static bool is_absolute_path(const std::string& p) {
107107
108108std::string ArgOptions::wrap_text (const std::string& text, size_t width, size_t indent) {
109109 std::ostringstream oss;
110- size_t line_len = 0 ;
111110 size_t pos = 0 ;
111+ size_t line_len = 0 ;
112112
113113 while (pos < text.size ()) {
114- // Preserve manual newlines
115114 if (text[pos] == ' \n ' ) {
116115 oss << ' \n '
117116 << std::string (indent, ' ' );
118- line_len = indent ;
117+ line_len = 0 ;
119118 ++pos;
120119 continue ;
121120 }
122121
123- // Add the character
124- oss << text[pos];
125- ++line_len;
126- ++pos;
127-
128- // If the current line exceeds width, try to break at the last space
129- if (line_len >= width) {
130- std::string current = oss.str ();
131- size_t back = current.size ();
132-
133- // Find the last space (for a clean break)
134- while (back > 0 && current[back - 1 ] != ' ' && current[back - 1 ] != ' \n ' )
135- --back;
136-
137- // If found a space to break on
138- if (back > 0 && current[back - 1 ] != ' \n ' ) {
139- std::string before = current.substr (0 , back - 1 );
140- std::string after = current.substr (back);
141- oss.str (" " );
142- oss.clear ();
143- oss << before << " \n "
144- << std::string (indent, ' ' ) << after;
145- } else {
146- // If no space found, just break at width
147- oss << " \n "
122+ if (std::isspace (static_cast <unsigned char >(text[pos]))) {
123+ ++pos;
124+ continue ;
125+ }
126+
127+ size_t word_start = pos;
128+ while (pos < text.size () &&
129+ text[pos] != ' \n ' &&
130+ !std::isspace (static_cast <unsigned char >(text[pos]))) {
131+ ++pos;
132+ }
133+
134+ std::string word = text.substr (word_start, pos - word_start);
135+ while (!word.empty ()) {
136+ size_t separator_len = line_len == 0 ? 0 : 1 ;
137+ if (line_len + separator_len + word.size () <= width) {
138+ if (separator_len > 0 ) {
139+ oss << ' ' ;
140+ ++line_len;
141+ }
142+ oss << word;
143+ line_len += word.size ();
144+ word.clear ();
145+ continue ;
146+ }
147+
148+ if (line_len > 0 ) {
149+ oss << ' \n '
150+ << std::string (indent, ' ' );
151+ line_len = 0 ;
152+ continue ;
153+ }
154+
155+ size_t chunk_len = std::min (width, word.size ());
156+ oss << word.substr (0 , chunk_len);
157+ line_len = chunk_len;
158+ word.erase (0 , chunk_len);
159+ if (!word.empty ()) {
160+ oss << ' \n '
148161 << std::string (indent, ' ' );
162+ line_len = 0 ;
149163 }
150- line_len = indent;
151164 }
152165 }
153166
@@ -783,7 +796,9 @@ ArgOptions SDGenerationParams::get_options() {
783796 &pm_id_embed_path},
784797 {" " ,
785798 " --hires-upscaler" ,
786- " highres fix upscaler, Latent (nearest) or a model name/path under --hires-upscalers-dir (default: Latent (nearest))" ,
799+ " highres fix upscaler, Lanczos, Nearest, Latent, Latent (nearest), Latent (nearest-exact), "
800+ " Latent (antialiased), Latent (bicubic), Latent (bicubic antialiased), or a model name "
801+ " under --hires-upscalers-dir (default: Latent)" ,
787802 &hires_upscaler},
788803 };
789804
@@ -1918,7 +1933,7 @@ bool SDGenerationParams::resolve(const std::string& lora_model_dir, const std::s
19181933 hires_upscaler_model_path.clear ();
19191934 if (hires_enabled) {
19201935 if (hires_upscaler.empty ()) {
1921- hires_upscaler = " Latent (nearest) " ;
1936+ hires_upscaler = " Latent" ;
19221937 }
19231938 resolved_hires_upscaler = str_to_sd_hires_upscaler (hires_upscaler.c_str ());
19241939 if (resolved_hires_upscaler == SD_HIRES_UPSCALER_NONE) {
0 commit comments